feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -36,7 +36,7 @@ void Corpse::AddToWorld()
{
///- Register the corpse for guid lookup
if (!IsInWorld())
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Corpse>(GetGUID(), this);
Object::AddToWorld();
}
@@ -45,19 +45,18 @@ void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if (IsInWorld())
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<Corpse>(GetGUID());
Object::RemoveFromWorld();
WorldObject::RemoveFromWorld();
}
bool Corpse::Create(uint32 guidlow, Map* map)
bool Corpse::Create(ObjectGuid::LowType guidlow)
{
SetMap(map);
Object::_Create(guidlow, 0, HIGHGUID_CORPSE);
Object::_Create(guidlow, 0, HighGuid::Corpse);
return true;
}
bool Corpse::Create(uint32 guidlow, Player* owner)
bool Corpse::Create(ObjectGuid::LowType guidlow, Player* owner)
{
ASSERT(owner);
@@ -70,16 +69,12 @@ bool Corpse::Create(uint32 guidlow, Player* owner)
return false;
}
//we need to assign owner's map for corpse
//in other way we will get a crash in Corpse::SaveToDB()
SetMap(owner->GetMap());
WorldObject::_Create(guidlow, HIGHGUID_CORPSE, owner->GetPhaseMask());
WorldObject::_Create(guidlow, HighGuid::Corpse, owner->GetPhaseMask());
SetObjectScale(1);
SetUInt64Value(CORPSE_FIELD_OWNER, owner->GetGUID());
SetGuidValue(CORPSE_FIELD_OWNER, owner->GetGUID());
_gridCoord = acore::ComputeGridCoord(GetPositionX(), GetPositionY());
_cellCoord = acore::ComputeCellCoord(GetPositionX(), GetPositionY());
return true;
}
@@ -91,24 +86,23 @@ void Corpse::SaveToDB()
DeleteFromDB(trans);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
stmt->setUInt32(0, GetGUIDLow()); // corpseGuid
stmt->setUInt32(1, GUID_LOPART(GetOwnerGUID())); // guid
stmt->setFloat (2, GetPositionX()); // posX
stmt->setFloat (3, GetPositionY()); // posY
stmt->setFloat (4, GetPositionZ()); // posZ
stmt->setFloat (5, GetOrientation()); // orientation
stmt->setUInt16(6, GetMapId()); // mapId
stmt->setUInt32(7, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
stmt->setString(8, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
stmt->setUInt32(11, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
stmt->setUInt8 (13, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
stmt->setUInt32(14, uint32(m_time)); // time
stmt->setUInt8 (15, GetType()); // corpseType
stmt->setUInt32(16, GetInstanceId()); // instanceId
stmt->setUInt32(17, GetPhaseMask()); // phaseMask
stmt->setUInt32(0, GetOwnerGUID().GetCounter()); // guid
stmt->setFloat (1, GetPositionX()); // posX
stmt->setFloat (2, GetPositionY()); // posY
stmt->setFloat (3, GetPositionZ()); // posZ
stmt->setFloat (4, GetOrientation()); // orientation
stmt->setUInt16(5, GetMapId()); // mapId
stmt->setUInt32(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
stmt->setString(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
stmt->setUInt32(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
stmt->setUInt8 (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
stmt->setUInt32(13, uint32(m_time)); // time
stmt->setUInt8 (14, GetType()); // corpseType
stmt->setUInt32(15, GetInstanceId()); // instanceId
stmt->setUInt32(16, GetPhaseMask()); // phaseMask
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
@@ -116,34 +110,29 @@ void Corpse::SaveToDB()
void Corpse::DeleteFromDB(SQLTransaction& trans)
{
PreparedStatement* stmt = nullptr;
if (GetType() == CORPSE_BONES)
{
// Only specific bones
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
stmt->setUInt32(0, GetGUIDLow());
}
else
{
// all corpses (not bones)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_CORPSES);
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
}
trans->Append(stmt);
DeleteFromDB(GetOwnerGUID(), trans);
}
bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
void Corpse::DeleteFromDB(ObjectGuid const ownerGuid, SQLTransaction& trans)
{
uint32 ownerGuid = fields[17].GetUInt32();
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, corpseGuid, guid FROM corpse WHERE corpseType <> 0
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
stmt->setUInt32(0, ownerGuid.GetCounter());
CharacterDatabase.ExecuteOrAppend(trans, stmt);
}
bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
{
ObjectGuid::LowType ownerGuid = fields[16].GetUInt32();
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
float posX = fields[0].GetFloat();
float posY = fields[1].GetFloat();
float posZ = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 mapId = fields[4].GetUInt16();
Object::_Create(guid, 0, HIGHGUID_CORPSE);
Object::_Create(guid, 0, HighGuid::Corpse);
SetObjectScale(1.0f);
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
@@ -153,7 +142,7 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32());
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt8());
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt8());
SetUInt64Value(CORPSE_FIELD_OWNER, MAKE_NEW_GUID(ownerGuid, 0, HIGHGUID_PLAYER));
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(ownerGuid));
m_time = time_t(fields[12].GetUInt32());
@@ -168,17 +157,21 @@ bool Corpse::LoadCorpseFromDB(uint32 guid, Field* fields)
if (!IsPositionValid())
{
LOG_ERROR("server", "Corpse (guid: %u, owner: %u) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), posX, posY, posZ);
LOG_ERROR("server", "Corpse ( %s, owner: %s) is not created, given coordinates are not valid (X: %f, Y: %f, Z: %f)",
GetGUID().ToString().c_str(), GetOwnerGUID().ToString().c_str(), posX, posY, posZ);
return false;
}
_gridCoord = acore::ComputeGridCoord(GetPositionX(), GetPositionY());
_cellCoord = acore::ComputeCellCoord(GetPositionX(), GetPositionY());
return true;
}
bool Corpse::IsExpired(time_t t) const
{
// Deleted character
if (!sWorld->GetGlobalPlayerData(GetOwnerGUID().GetCounter()))
return true;
if (m_type == CORPSE_BONES)
return m_time < t - 60 * MINUTE;
else

View File

@@ -43,22 +43,23 @@ public:
void AddToWorld() override;
void RemoveFromWorld() override;
bool Create(uint32 guidlow, Map* map);
bool Create(uint32 guidlow, Player* owner);
bool Create(ObjectGuid::LowType guidlow);
bool Create(ObjectGuid::LowType guidlow, Player* owner);
void SaveToDB();
bool LoadCorpseFromDB(uint32 guid, Field* fields);
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields);
void DeleteFromDB(SQLTransaction& trans);
static void DeleteFromDB(ObjectGuid const ownerGuid, SQLTransaction& trans);
[[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(CORPSE_FIELD_OWNER); }
[[nodiscard]] time_t const& GetGhostTime() const { return m_time; }
void ResetGhostTime() { m_time = time(nullptr); }
[[nodiscard]] CorpseType GetType() const { return m_type; }
[[nodiscard]] GridCoord const& GetGridCoord() const { return _gridCoord; }
void SetGridCoord(GridCoord const& gridCoord) { _gridCoord = gridCoord; }
CellCoord const& GetCellCoord() const { return _cellCoord; }
void SetCellCoord(CellCoord const& cellCoord) { _cellCoord = cellCoord; }
Loot loot; // remove insignia ONLY at BG
Player* lootRecipient;
@@ -68,6 +69,6 @@ public:
private:
CorpseType m_type;
time_t m_time;
GridCoord _gridCoord; // gride for corpse position for fast search
CellCoord _cellCoord;
};
#endif

View File

@@ -163,10 +163,10 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
return true;
}
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipient(0), m_lootRecipientGroup(0),
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false),
m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(nullptr), m_cannotReachTarget(false), m_cannotReachTimer(0),
_isMissingSwimmingFlagOutOfCombat(false)
@@ -217,10 +217,16 @@ void Creature::AddToWorld()
if (GetZoneScript())
GetZoneScript()->OnCreatureCreate(this);
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Creature>(GetGUID(), this);
if (m_spawnId)
GetMap()->GetCreatureBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
Unit::AddToWorld();
SearchFormation();
AIM_Initialize();
if (IsVehicle())
GetVehicleKit()->Install();
#ifdef ELUNA
@@ -238,12 +244,19 @@ void Creature::RemoveFromWorld()
#endif
if (GetZoneScript())
GetZoneScript()->OnCreatureRemove(this);
if (m_formation)
sFormationMgr->RemoveCreatureFromGroup(m_formation, this);
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
Unit::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
if (m_spawnId)
acore::Containers::MultimapErasePair(GetMap()->GetCreatureBySpawnIdStore(), m_spawnId, this);
GetMap()->GetObjectsStore().Remove<Creature>(GetGUID());
}
}
@@ -262,11 +275,11 @@ void Creature::SearchFormation()
if (IsSummon())
return;
uint32 lowguid = GetDBTableGUIDLow();
if (!lowguid)
ObjectGuid::LowType spawnId = GetSpawnId();
if (!spawnId)
return;
CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(lowguid);
CreatureGroupInfoType::iterator frmdata = sFormationMgr->CreatureGroupMap.find(spawnId);
if (frmdata != sFormationMgr->CreatureGroupMap.end())
sFormationMgr->AddCreatureToGroup(frmdata->second->leaderGUID, this);
}
@@ -520,11 +533,11 @@ void Creature::Update(uint32 diff)
{
case JUST_RESPAWNED:
// Must not be called, see Creature::setDeathState JUST_RESPAWNED -> ALIVE promoting.
LOG_ERROR("server", "Creature (GUID: %u Entry: %u) in wrong state: JUST_RESPAWNED (4)", GetGUIDLow(), GetEntry());
LOG_ERROR("server", "Creature (%s) in wrong state: JUST_RESPAWNED (4)", GetGUID().ToString().c_str());
break;
case JUST_DIED:
// Must not be called, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
LOG_ERROR("server", "Creature (GUID: %u Entry: %u) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry());
LOG_ERROR("server", "Creature (%s) in wrong state: JUST_DEAD (1)", GetGUID().ToString().c_str());
break;
case DEAD:
{
@@ -535,13 +548,13 @@ void Creature::Update(uint32 diff)
if (!allowed) // Will be rechecked on next Update call
break;
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_UNIT);
ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::Unit>(GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (!linkedRespawntime) // Can respawn
Respawn();
else // the master is dead
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
@@ -695,7 +708,7 @@ void Creature::Update(uint32 diff)
if (IsInWorld() && !IsDuringRemoveFromWorld())
{
// pussywizard:
if (IS_PLAYER_GUID(GetOwnerGUID()))
if (GetOwnerGUID().IsPlayer())
{
if (m_transportCheckTimer <= diff)
{
@@ -739,7 +752,7 @@ void Creature::Regenerate(Powers power)
uint32 maxValue = GetMaxPower(power);
// Xinef: implement power regeneration flag
if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER) && !IS_PLAYER_GUID(GetOwnerGUID()))
if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER) && !GetOwnerGUID().IsPlayer())
return;
if (curValue >= maxValue)
@@ -892,7 +905,7 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
i_AI->InitializeAI();
// Xinef: Initialize vehicle if it is not summoned!
if (GetVehicleKit() && GetDBTableGUIDLow())
if (GetVehicleKit() && m_spawnId)
GetVehicleKit()->Reset();
return true;
}
@@ -912,7 +925,7 @@ void Creature::Motion_Initialize()
GetMotionMaster()->Initialize();
}
bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data)
bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data)
{
ASSERT(map);
SetMap(map);
@@ -1088,7 +1101,7 @@ Player* Creature::GetLootRecipient() const
{
if (!m_lootRecipient)
return nullptr;
return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient);
return ObjectAccessor::FindConnectedPlayer(m_lootRecipient);
}
Group* Creature::GetLootRecipientGroup() const
@@ -1106,7 +1119,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
if (!unit)
{
m_lootRecipient = 0;
m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE | UNIT_DYNFLAG_TAPPED);
return;
@@ -1124,7 +1137,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
if (withGroup)
{
if (Group* group = player->GetGroup())
m_lootRecipientGroup = group->GetLowGUID();
m_lootRecipientGroup = group->GetGUID().GetCounter();
}
else
m_lootRecipientGroup = 0;
@@ -1149,7 +1162,7 @@ void Creature::SaveToDB()
{
// this should only be used when the creature has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise
CreatureData const* data = sObjectMgr->GetCreatureData(m_DBTableGuid);
CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId);
if (!data)
{
LOG_ERROR("server", "Creature::SaveToDB failed, cannot get creature data!");
@@ -1163,9 +1176,10 @@ void Creature::SaveToDB()
void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{
// update in loaded data
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_DBTableGuid);
if (!m_spawnId)
m_spawnId = sObjectMgr->GenerateCreatureSpawnId();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_spawnId);
uint32 displayId = GetNativeDisplayId();
uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
@@ -1190,7 +1204,6 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
dynamicflags = 0;
}
// data->guid = guid must not be updated at save
data.id = GetEntry();
data.mapid = mapid;
data.phaseMask = phaseMask;
@@ -1229,13 +1242,13 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
SQLTransaction trans = WorldDatabase.BeginTransaction();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
uint8 index = 0;
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
@@ -1377,7 +1390,7 @@ float Creature::GetSpellDamageMod(int32 Rank)
}
}
bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data)
bool Creature::CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data)
{
SetZoneScript();
if (GetZoneScript() && data)
@@ -1396,7 +1409,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const
SetOriginalEntry(Entry);
Object::_Create(guidlow, Entry, (vehId || normalInfo->VehicleId) ? HIGHGUID_VEHICLE : HIGHGUID_UNIT);
Object::_Create(guidlow, Entry, (vehId || normalInfo->VehicleId) ? HighGuid::Vehicle : HighGuid::Unit);
// Xinef: select proper vehicle id
if (!vehId)
@@ -1434,13 +1447,42 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const
return true;
}
bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gridLoad)
bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool gridLoad, bool allowDuplicate /*= false*/)
{
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
if (!allowDuplicate)
{
// If an alive instance of this spawnId is already found, skip creation
// If only dead instance(s) exist, despawn them and spawn a new (maybe also dead) version
const auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(spawnId);
std::vector <Creature*> despawnList;
if (creatureBounds.first != creatureBounds.second)
{
for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr)
{
if (itr->second->IsAlive())
{
LOG_DEBUG("maps", "Would have spawned %u but %s already exists", spawnId, creatureBounds.first->second->GetGUID().ToString().c_str());
return false;
}
else
{
despawnList.push_back(itr->second);
LOG_DEBUG("maps", "Despawned dead instance of spawn %u (%s)", spawnId, itr->second->GetGUID().ToString().c_str());
}
}
for (Creature* despawnCreature : despawnList)
{
despawnCreature->AddObjectToRemoveList();
}
}
}
CreatureData const* data = sObjectMgr->GetCreatureData(spawnId);
if (!data)
{
LOG_ERROR("sql.sql", "Creature (GUID: %u) not found in table `creature`, can't load. ", guid);
LOG_ERROR("sql.sql", "Creature (SpawnId: %u) not found in table `creature`, can't load. ", spawnId);
return false;
}
@@ -1456,17 +1498,9 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
// xinef: this has to be assigned before Create function, properly loads equipment id from DB
m_creatureData = data;
m_DBTableGuid = guid;
m_spawnId = spawnId;
if (map->GetInstanceId() == 0)
{
if (map->GetCreature(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT)))
return false;
}
else
guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT);
if (!Create(guid, map, data->phaseMask, data->id, 0, data->posX, data->posY, data->posZ, data->orientation, data))
if (!Create(map->GenerateLowGuid<HighGuid::Unit>(), map, data->phaseMask, data->id, 0, data->posX, data->posY, data->posZ, data->orientation, data))
return false;
//We should set first home position, because then AI calls home movement
@@ -1477,7 +1511,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap, bool gri
m_respawnDelay = data->spawntimesecs;
m_deathState = ALIVE;
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_DBTableGuid);
m_respawnTime = GetMap()->GetCreatureRespawnTime(m_spawnId);
if (m_respawnTime) // respawn on Update
{
m_deathState = DEAD;
@@ -1572,31 +1606,31 @@ bool Creature::hasInvolvedQuest(uint32 quest_id) const
void Creature::DeleteFromDB()
{
if (!m_DBTableGuid)
if (!m_spawnId)
{
LOG_ERROR("server", "Trying to delete not saved creature! LowGUID: %u, Entry: %u", GetGUIDLow(), GetEntry());
LOG_ERROR("server", "Trying to delete not saved creature: %s", GetGUID().ToString().c_str());
return;
}
GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid);
sObjectMgr->DeleteCreatureData(m_DBTableGuid);
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
sObjectMgr->DeleteCreatureData(m_spawnId);
SQLTransaction trans = WorldDatabase.BeginTransaction();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
@@ -1683,7 +1717,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
if (GetMap()->IsDungeon() || isWorldBoss() || GetCreatureTemplate()->rank >= CREATURE_ELITE_ELITE)
SaveRespawnTime();
SetTarget(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetTarget(); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
Dismount(); // if creature is mounted on a virtual mount, remove it at death
@@ -1761,11 +1795,11 @@ void Creature::Respawn(bool force)
if (getDeathState() == DEAD)
{
if (m_DBTableGuid)
GetMap()->RemoveCreatureRespawnTime(m_DBTableGuid);
if (m_spawnId)
GetMap()->RemoveCreatureRespawnTime(m_spawnId);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("server", "Respawning creature %s (GuidLow: %u, Full GUID: " UI64FMTD " Entry: %u)", GetName().c_str(), GetGUIDLow(), GetGUID(), GetEntry());
LOG_DEBUG("server", "Respawning creature %s (SpawnId: %u, %s)", GetName().c_str(), GetSpawnId(), GetGUID().ToString().c_str());
#endif
m_respawnTime = 0;
ResetPickPocketLootTime();
@@ -1796,9 +1830,9 @@ void Creature::Respawn(bool force)
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
}
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<Creature>(m_spawnId) : 0;
if (poolid)
sPoolMgr->UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<Creature>(poolid, m_spawnId);
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
@@ -1848,7 +1882,7 @@ void Creature::InitializeReactState()
bool Creature::HasMechanicTemplateImmunity(uint32 mask) const
{
return !IS_PLAYER_GUID(GetOwnerGUID()) && (GetCreatureTemplate()->MechanicImmuneMask & mask);
return !GetOwnerGUID().IsPlayer() && (GetCreatureTemplate()->MechanicImmuneMask & mask);
}
void Creature::LoadSpellTemplateImmunity()
@@ -1864,7 +1898,7 @@ void Creature::LoadSpellTemplateImmunity()
}
// don't inherit immunities for hunter pets
if (IS_PLAYER_GUID(GetOwnerGUID()) && IsHunterPet())
if (GetOwnerGUID().IsPlayer() && IsHunterPet())
{
return;
}
@@ -2071,7 +2105,7 @@ void Creature::SendAIReaction(AiReaction reactionType)
{
WorldPacket data(SMSG_AI_REACTION, 12);
data << uint64(GetGUID());
data << GetGUID();
data << uint32(reactionType);
((WorldObject*)this)->SendMessageToSet(&data, true);
@@ -2262,10 +2296,10 @@ void Creature::UpdateMoveInLineOfSightState()
void Creature::SaveRespawnTime()
{
if (IsSummon() || !GetDBTableGUIDLow() || (m_creatureData && !m_creatureData->dbData))
if (IsSummon() || !m_spawnId || (m_creatureData && !m_creatureData->dbData))
return;
GetMap()->SaveCreatureRespawnTime(GetDBTableGUIDLow(), m_respawnTime);
GetMap()->SaveCreatureRespawnTime(m_spawnId, m_respawnTime);
}
bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
@@ -2296,7 +2330,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
return false;
}
if (!IS_PLAYER_GUID(GetCharmerOrOwnerGUID()))
if (!GetCharmerOrOwnerGUID().IsPlayer())
{
if (GetMap()->IsDungeon())
return true;
@@ -2327,9 +2361,9 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
CreatureAddon const* Creature::GetCreatureAddon() const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_DBTableGuid))
if (CreatureAddon const* addon = sObjectMgr->GetCreatureAddon(m_spawnId))
return addon;
}
@@ -2407,7 +2441,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(*itr);
if (!AdditionalSpellInfo)
{
LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has wrong spell %u defined in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
LOG_ERROR("sql.sql", "Creature (%s) has wrong spell %u defined in `auras` field.", GetGUID().ToString().c_str(), *itr);
continue;
}
@@ -2415,14 +2449,14 @@ bool Creature::LoadCreaturesAddon(bool reload)
if (HasAura(*itr))
{
if (!reload)
LOG_ERROR("sql.sql", "Creature (GUID: %u Entry: %u) has duplicate aura (spell %u) in `auras` field.", GetGUIDLow(), GetEntry(), *itr);
LOG_ERROR("sql.sql", "Creature (%s) has duplicate aura (spell %u) in `auras` field.", GetGUID().ToString().c_str(), *itr);
continue;
}
AddAura(*itr, this);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
LOG_DEBUG("entities.unit", "Spell: %u added to creature (%s)", *itr, GetGUID().ToString().c_str());
#endif
}
}
@@ -2576,9 +2610,9 @@ time_t Creature::GetRespawnTimeEx() const
void Creature::GetRespawnPosition(float& x, float& y, float& z, float* ori, float* dist) const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (CreatureData const* data = sObjectMgr->GetCreatureData(GetDBTableGUIDLow()))
if (CreatureData const* data = sObjectMgr->GetCreatureData(m_spawnId))
{
x = data->posX;
y = data->posY;
@@ -2775,7 +2809,7 @@ void Creature::SetPosition(float x, float y, float z, float o)
bool Creature::IsDungeonBoss() const
{
if (IS_PLAYER_GUID(GetOwnerGUID()))
if (GetOwnerGUID().IsPlayer())
return false;
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
@@ -2784,7 +2818,7 @@ bool Creature::IsDungeonBoss() const
bool Creature::IsImmuneToKnockback() const
{
if (IS_PLAYER_GUID(GetOwnerGUID()))
if (GetOwnerGUID().IsPlayer())
return false;
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(GetEntry());
@@ -2797,7 +2831,7 @@ bool Creature::SetWalk(bool enable)
return false;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, false);
return true;
}
@@ -2815,7 +2849,7 @@ bool Creature::SetDisableGravity(bool disable, bool packetOnly/*=false*/)
return true;
WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, false);
return true;
}
@@ -2849,7 +2883,7 @@ bool Creature::SetSwim(bool enable)
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, true);
return true;
}
@@ -2866,7 +2900,7 @@ bool Creature::CanSwim() const
if (Unit::CanSwim())
return true;
if (IsPet() || IS_PLAYER_GUID(GetOwnerGUID()))
if (IsPet() || GetOwnerGUID().IsPlayer())
return true;
return false;
@@ -2900,7 +2934,7 @@ bool Creature::SetCanFly(bool enable, bool /*packetOnly*/ /* = false */)
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, false);
return true;
}
@@ -2922,7 +2956,7 @@ bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */)
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, true);
return true;
}
@@ -2936,7 +2970,7 @@ bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */)
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, true);
return true;
}
@@ -2953,7 +2987,7 @@ bool Creature::SetHover(bool enable, bool packetOnly /*= false*/)
//! Not always a packet is sent
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9);
data.append(GetPackGUID());
data << GetPackGUID();
SendMessageToSet(&data, false);
return true;
}
@@ -3038,10 +3072,10 @@ void Creature::SetDisplayId(uint32 modelId)
SetFloatValue(UNIT_FIELD_COMBATREACH, combatReach * GetObjectScale());
}
void Creature::SetTarget(uint64 guid)
void Creature::SetTarget(ObjectGuid guid)
{
if (!_focusSpell)
SetUInt64Value(UNIT_FIELD_TARGET, guid);
SetGuidValue(UNIT_FIELD_TARGET, guid);
}
void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
@@ -3051,7 +3085,7 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target)
return;
_focusSpell = focusSpell;
SetUInt64Value(UNIT_FIELD_TARGET, this == target ? 0 : target->GetGUID());
SetGuidValue(UNIT_FIELD_TARGET, this == target ? ObjectGuid::Empty : target->GetGUID());
if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST))
AddUnitState(UNIT_STATE_ROTATING);
@@ -3080,9 +3114,9 @@ void Creature::ReleaseFocus(Spell const* focusSpell)
_focusSpell = nullptr;
if (Unit* victim = GetVictim())
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
SetGuidValue(UNIT_FIELD_TARGET, victim->GetGUID());
else
SetUInt64Value(UNIT_FIELD_TARGET, 0);
SetGuidValue(UNIT_FIELD_TARGET, ObjectGuid::Empty);
if (focusSpell->GetSpellInfo()->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST))
ClearUnitState(UNIT_STATE_ROTATING);

View File

@@ -444,12 +444,12 @@ public:
void DisappearAndDie();
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData* data = nullptr);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel(bool changelevel = true);
void LoadEquipment(int8 id = 1, bool force = false);
[[nodiscard]] uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
[[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
void Update(uint32 time) override; // overwrited Unit::Update
void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr, float* dist = nullptr) const;
@@ -527,7 +527,7 @@ public:
{
::Spell const* Spell = nullptr;
uint32 Delay = 0; // ms until the creature's target should snap back (0 = no snapback scheduled)
uint64 Target; // the creature's "real" target while casting
ObjectGuid Target; // the creature's "real" target while casting
float Orientation = 0.0f; // the creature's "real" orientation while casting
} _spellFocusInfo;
@@ -584,15 +584,15 @@ public:
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
bool LoadFromDB(uint32 guid, Map* map) { return LoadCreatureFromDB(guid, map, false, true); }
bool LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap = true, bool gridLoad = false);
bool LoadFromDB(ObjectGuid::LowType guid, Map* map, bool allowDuplicate = false) { return LoadCreatureFromDB(guid, map, false, true, allowDuplicate); }
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true, bool gridLoad = false, bool allowDuplicate = false);
void SaveToDB();
// overriden in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
virtual void DeleteFromDB(); // overriden in Pet
Loot loot;
[[nodiscard]] uint64 GetLootRecipientGUID() const { return m_lootRecipient; }
[[nodiscard]] ObjectGuid GetLootRecipientGUID() const { return m_lootRecipient; }
[[nodiscard]] Player* GetLootRecipient() const;
[[nodiscard]] Group* GetLootRecipientGroup() const;
[[nodiscard]] bool hasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
@@ -733,7 +733,7 @@ public:
bool m_isTempWorldObject; //true when possessed
// Handling caster facing during spellcast
void SetTarget(uint64 guid) override;
void SetTarget(ObjectGuid guid = ObjectGuid::Empty) override;
void FocusTarget(Spell const* focusSpell, WorldObject const* target);
void ReleaseFocus(Spell const* focusSpell);
bool IsMovementPreventedByCasting() const;
@@ -757,7 +757,7 @@ public:
void RefreshSwimmingFlag(bool recheck = false);
protected:
bool CreateFromProto(uint32 guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
bool InitEntry(uint32 entry, const CreatureData* data = nullptr);
// vendor items
@@ -765,7 +765,7 @@ protected:
static float _GetHealthMod(int32 Rank);
uint64 m_lootRecipient;
ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
/// Timers
@@ -782,7 +782,7 @@ protected:
void RegenerateHealth();
void Regenerate(Powers power);
MovementGeneratorType m_defaultMovementType;
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
ObjectGuid::LowType m_spawnId; ///< For new or temporary creatures is 0 for saved it is lowguid
uint8 m_equipmentId;
int8 m_originalEquipmentId; // can be -1
@@ -838,15 +838,16 @@ private:
class AssistDelayEvent : public BasicEvent
{
public:
AssistDelayEvent(uint64 victim, Creature* owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
AssistDelayEvent(ObjectGuid victim, Creature* owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
bool Execute(uint64 e_time, uint32 p_time) override;
void AddAssistant(uint64 guid) { m_assistants.push_back(guid); }
void AddAssistant(ObjectGuid guid) { m_assistants.push_back(guid); }
private:
AssistDelayEvent();
uint64 m_victim;
std::list<uint64> m_assistants;
ObjectGuid m_victim;
GuidList m_assistants;
Creature* m_owner;
};

View File

@@ -34,7 +34,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member)
if (itr != map->CreatureGroupHolder.end())
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "Group found: %u, inserting creature GUID: %u, Group InstanceID %u", groupId, member->GetGUIDLow(), member->GetInstanceId());
LOG_DEBUG("entities.unit", "Group found: %u, inserting creature %s, Group InstanceID %u", groupId, member->GetGUID().ToString().c_str(), member->GetInstanceId());
#endif
itr->second->AddMember(member);
}
@@ -53,7 +53,7 @@ void FormationMgr::AddCreatureToGroup(uint32 groupId, Creature* member)
void FormationMgr::RemoveCreatureFromGroup(CreatureGroup* group, Creature* member)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "Deleting member pointer to GUID: %u from group %u", group->GetId(), member->GetDBTableGUIDLow());
LOG_DEBUG("entities.unit", "Deleting member pointer to spawnId: %u from group %u", member->GetSpawnId(), group->GetId());
#endif
group->RemoveMember(member);
@@ -100,7 +100,7 @@ void FormationMgr::LoadCreatureFormations()
//Load group member data
group_member = new FormationInfo();
group_member->leaderGUID = fields[0].GetUInt32();
uint32 memberGUID = fields[1].GetUInt32();
ObjectGuid::LowType memberGUID = fields[1].GetUInt32();
group_member->groupAI = fields[4].GetUInt32();
group_member->point_1 = fields[5].GetUInt16();
group_member->point_2 = fields[6].GetUInt16();
@@ -144,19 +144,19 @@ void FormationMgr::LoadCreatureFormations()
void CreatureGroup::AddMember(Creature* member)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit GUID: %u.", member->GetGUIDLow());
LOG_DEBUG("entities.unit", "CreatureGroup::AddMember: Adding unit %s.", member->GetGUID().ToString().c_str());
#endif
//Check if it is a leader
if (member->GetDBTableGUIDLow() == m_groupID)
if (member->GetSpawnId() == m_groupID)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "Unit GUID: %u is formation leader. Adding group.", member->GetGUIDLow());
LOG_DEBUG("entities.unit", "Unit %s is formation leader. Adding group.", member->GetGUID().ToString().c_str());
#endif
m_leader = member;
}
m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetDBTableGUIDLow())->second;
m_members[member] = sFormationMgr->CreatureGroupMap.find(member->GetSpawnId())->second;
member->SetFormation(this);
}
@@ -171,7 +171,7 @@ void CreatureGroup::RemoveMember(Creature* member)
void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
{
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetSpawnId()]->groupAI;
if (!groupAI)
return;
@@ -214,7 +214,7 @@ void CreatureGroup::FormationReset(bool dismiss)
else
itr->first->GetMotionMaster()->MoveIdle();
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.unit", "Set %s movement for member GUID: %u", dismiss ? "default" : "idle", itr->first->GetGUIDLow());
LOG_DEBUG("entities.unit", "Set %s movement for member %s", dismiss ? "default" : "idle", itr->first->GetGUID().ToString().c_str());
#endif
}
}
@@ -228,7 +228,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z, bool run)
if (!m_leader)
return;
uint8 groupAI = sFormationMgr->CreatureGroupMap[m_leader->GetDBTableGUIDLow()]->groupAI;
uint8 groupAI = sFormationMgr->CreatureGroupMap[m_leader->GetSpawnId()]->groupAI;
if (groupAI == 5)
return;

View File

@@ -17,7 +17,7 @@ class CreatureGroup;
struct FormationInfo
{
uint32 leaderGUID;
ObjectGuid::LowType leaderGUID;
float follow_dist;
float follow_angle;
uint8 groupAI;
@@ -25,7 +25,7 @@ struct FormationInfo
uint16 point_2;
};
typedef std::unordered_map<uint32/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
typedef std::unordered_map<ObjectGuid::LowType/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
class FormationMgr
{

View File

@@ -177,10 +177,10 @@ void PlayerMenu::ClearMenus()
_questMenu.ClearMenu();
}
void PlayerMenu::SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const
void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) const
{
WorldPacket data(SMSG_GOSSIP_MESSAGE, 24 + _gossipMenu.GetMenuItemCount() * 100 + _questMenu.GetMenuItemCount() * 75); // guess size
data << uint64(objectGUID);
data << objectGUID;
data << uint32(_gossipMenu.GetMenuId()); // new 2.4.0
data << uint32(titleTextId);
data << uint32(_gossipMenu.GetMenuItemCount()); // max count 0x10
@@ -297,10 +297,10 @@ void QuestMenu::ClearMenu()
_questMenuItems.clear();
}
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID)
void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID)
{
WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100 + _questMenu.GetMenuItemCount() * 75); // guess size
data << uint64(npcGUID);
data << npcGUID;
data << Title;
data << uint32(eEmote._Delay); // player emote
data << uint32(eEmote._Emote); // NPC emote
@@ -335,23 +335,23 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string
data.put<uint8>(count_pos, count);
_session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC %s", npcGUID.ToString().c_str());
#endif
}
void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const
void PlayerMenu::SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID) const
{
WorldPacket data(SMSG_QUESTGIVER_STATUS, 9);
data << uint64(npcGUID);
data << npcGUID;
data << uint8(questStatus);
_session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC Guid=%u, status=%u", GUID_LOPART(npcGUID), questStatus);
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_STATUS NPC %s, status=%u", npcGUID.ToString().c_str(), questStatus);
#endif
}
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const
void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const
{
std::string questTitle = quest->GetTitle();
std::string questDetails = quest->GetDetails();
@@ -368,8 +368,8 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
}
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size
data << uint64(npcGUID);
data << uint64(_session->GetPlayer()->GetDivider());
data << npcGUID;
data << _session->GetPlayer()->GetDivider();
data << uint32(quest->GetQuestId());
data << questTitle;
data << questDetails;
@@ -451,7 +451,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
_session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_DETAILS %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
#endif
}
@@ -588,7 +588,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
#endif
}
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const
{
std::string questTitle = quest->GetTitle();
std::string RewardText = quest->GetOfferRewardText();
@@ -601,7 +601,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
data << uint64(npcGUID);
data << npcGUID;
data << uint32(quest->GetQuestId());
data << questTitle;
data << RewardText;
@@ -674,11 +674,11 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
_session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_OFFER_REWARD %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
#endif
}
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const
{
// We can always call to RequestItems, but this packet only goes out if there are actually
// items. Otherwise, we'll skip straight to the OfferReward
@@ -717,7 +717,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
}
WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 300); // guess size
data << uint64(npcGUID);
data << npcGUID;
data << uint32(quest->GetQuestId());
data << questTitle;
data << requestItemsText;
@@ -767,6 +767,6 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
_session->SendPacket(&data);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS %s, questid=%u", npcGUID.ToString().c_str(), quest->GetQuestId());
#endif
}

View File

@@ -12,6 +12,7 @@
#include "QuestDef.h"
class WorldSession;
class ObjectGuid;
#define GOSSIP_MAX_MENU_ITEMS 32
#define DEFAULT_GOSSIP_MESSAGE 0xffffff
@@ -253,22 +254,22 @@ public:
[[nodiscard]] uint32 GetGossipOptionAction(uint32 selection) const { return _gossipMenu.GetMenuItemAction(selection); }
[[nodiscard]] bool IsGossipOptionCoded(uint32 selection) const { return _gossipMenu.IsMenuItemCoded(selection); }
void SendGossipMenu(uint32 titleTextId, uint64 objectGUID) const;
void SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) const;
void SendCloseGossip() const;
void SendPointOfInterest(uint32 poiId) const;
/*********************************************************/
/*** QUEST SYSTEM ***/
/*********************************************************/
void SendQuestGiverStatus(uint8 questStatus, uint64 npcGUID) const;
void SendQuestGiverStatus(uint8 questStatus, ObjectGuid npcGUID) const;
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, uint64 npcGUID);
void SendQuestGiverQuestList(QEmote const& eEmote, const std::string& Title, ObjectGuid npcGUID);
void SendQuestQueryResponse(Quest const* quest) const;
void SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID, bool activateAccept) const;
void SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGUID, bool activateAccept) const;
void SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const;
void SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUID, bool enableNext) const;
void SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGUID, bool canComplete, bool closeOnCancel) const;
private:
GossipMenu _gossipMenu;

View File

@@ -13,7 +13,7 @@
#include "ScriptMgr.h"
#include "TemporarySummon.h"
TempSummon::TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) :
TempSummon::TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) :
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
m_timer(0), m_lifetime(0)
{
@@ -260,7 +260,7 @@ void TempSummon::RemoveFromWorld()
if (uint32 slot = m_Properties->Slot)
if (Unit* owner = GetSummoner())
if (owner->m_SummonSlot[slot] == GetGUID())
owner->m_SummonSlot[slot] = 0;
owner->m_SummonSlot[slot].Clear();
//if (GetOwnerGUID())
// LOG_ERROR("server", "Unit %u has owner guid when removed from world", GetEntry());
@@ -268,7 +268,7 @@ void TempSummon::RemoveFromWorld()
Creature::RemoveFromWorld();
}
Minion::Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject)
Minion::Minion(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject)
, m_owner(owner)
{
ASSERT(m_owner);
@@ -325,7 +325,7 @@ void Minion::setDeathState(DeathState s, bool despawn)
}
}
Guardian::Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject) : Minion(properties, owner, isWorldObject)
Guardian::Guardian(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : Minion(properties, owner, isWorldObject)
{
m_unitTypeMask |= UNIT_MASK_GUARDIAN;
if (properties && properties->Type == SUMMON_TYPE_PET)
@@ -359,9 +359,9 @@ void Guardian::InitSummon()
m_owner->ToPlayer()->CharmSpellInitialize();
}
Puppet::Puppet(SummonPropertiesEntry const* properties, uint64 owner) : Minion(properties, owner, false), m_owner(owner) //maybe true?
Puppet::Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false), m_owner(owner) //maybe true?
{
ASSERT(IS_PLAYER_GUID(owner));
ASSERT(owner.IsPlayer());
m_unitTypeMask |= UNIT_MASK_PUPPET;
}
@@ -378,7 +378,7 @@ void Puppet::InitSummon()
if (!SetCharmedBy(GetOwner(), CHARM_TYPE_POSSESS))
{
if (Player* p = GetOwner())
LOG_INFO("misc", "Puppet::InitSummon (A1) - %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u", p->GetTypeId(), p->GetEntry(), p->GetUnitTypeMask(), p->GetGUIDLow(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0);
LOG_INFO("misc", "Puppet::InitSummon (A1) - %s, %u, %u, %u, %u, %u, %u, %u", p->GetGUID().ToString().c_str(), p->GetMapId(), p->GetInstanceId(), p->FindMap()->GetId(), p->IsInWorld() ? 1 : 0, p->IsDuringRemoveFromWorld() ? 1 : 0, p->IsBeingTeleported() ? 1 : 0, p->isBeingLoaded() ? 1 : 0);
else
{
LOG_INFO("misc", "Puppet::InitSummon (B1)");

View File

@@ -28,7 +28,7 @@ struct TempSummonData
class TempSummon : public Creature
{
public:
explicit TempSummon(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
explicit TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject);
~TempSummon() override = default;
void Update(uint32 time) override;
virtual void InitStats(uint32 lifetime);
@@ -38,7 +38,7 @@ public:
void SetTempSummonType(TempSummonType type);
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override {}
[[nodiscard]] Unit* GetSummoner() const;
uint64 GetSummonerGUID() { return m_summonerGUID; }
ObjectGuid GetSummonerGUID() { return m_summonerGUID; }
TempSummonType const& GetSummonType() { return m_type; }
uint32 GetTimer() { return m_timer; }
void SetTimer(uint32 t) { m_timer = t; }
@@ -48,13 +48,13 @@ private:
TempSummonType m_type;
uint32 m_timer;
uint32 m_lifetime;
uint64 m_summonerGUID;
ObjectGuid m_summonerGUID;
};
class Minion : public TempSummon
{
public:
Minion(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
Minion(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject);
void InitStats(uint32 duration) override;
void RemoveFromWorld() override;
[[nodiscard]] Unit* GetOwner() const;
@@ -64,14 +64,14 @@ public:
[[nodiscard]] bool IsGuardianPet() const;
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
protected:
const uint64 m_owner;
const ObjectGuid m_owner;
float m_followAngle;
};
class Guardian : public Minion
{
public:
Guardian(SummonPropertiesEntry const* properties, uint64 owner, bool isWorldObject);
Guardian(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject);
void InitStats(uint32 duration) override;
bool InitStatsForLevel(uint8 level);
void InitSummon() override;
@@ -88,14 +88,14 @@ public:
class Puppet : public Minion
{
public:
Puppet(SummonPropertiesEntry const* properties, uint64 owner);
Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner);
void InitStats(uint32 duration) override;
void InitSummon() override;
void Update(uint32 time) override;
void RemoveFromWorld() override;
protected:
[[nodiscard]] Player* GetOwner() const;
const uint64 m_owner;
const ObjectGuid m_owner;
};
class ForcedUnsummonDelayEvent : public BasicEvent

View File

@@ -54,8 +54,10 @@ void DynamicObject::AddToWorld()
///- Register the dynamicObject for guid lookup and for caster
if (!IsInWorld())
{
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<DynamicObject>(GetGUID(), this);
WorldObject::AddToWorld();
BindToCaster();
}
}
@@ -76,14 +78,17 @@ void DynamicObject::RemoveFromWorld()
return;
UnbindFromCaster();
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<DynamicObject>(GetGUID());
}
}
bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type)
bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type)
{
SetMap(caster->GetMap());
Relocate(pos);
@@ -93,11 +98,11 @@ bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spe
return false;
}
WorldObject::_Create(guidlow, HIGHGUID_DYNAMICOBJECT, caster->GetPhaseMask());
WorldObject::_Create(guidlow, HighGuid::DynamicObject, caster->GetPhaseMask());
SetEntry(spellId);
SetObjectScale(1);
SetUInt64Value(DYNAMICOBJECT_CASTER, caster->GetGUID());
SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());
// The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden
// by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.

View File

@@ -31,7 +31,7 @@ public:
void CleanupsBeforeDelete(bool finalCleanup = true) override;
bool CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type);
bool CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type);
void Update(uint32 p_time) override;
void Remove();
void SetDuration(int32 newDuration);
@@ -45,7 +45,7 @@ public:
void BindToCaster();
void UnbindFromCaster();
[[nodiscard]] uint32 GetSpellId() const { return GetUInt32Value(DYNAMICOBJECT_SPELLID); }
[[nodiscard]] uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
[[nodiscard]] ObjectGuid GetCasterGUID() const { return GetGuidValue(DYNAMICOBJECT_CASTER); }
[[nodiscard]] float GetRadius() const { return GetFloatValue(DYNAMICOBJECT_RADIUS); }
[[nodiscard]] bool IsViewpoint() const { return _isViewpoint; }

View File

@@ -47,13 +47,11 @@ GameObject::GameObject() : WorldObject(false), MovableMapObject(),
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = nullptr;
m_ritualOwnerGUIDLow = 0;
m_goData = nullptr;
m_packedRotation = 0;
m_DBTableGuid = 0;
m_spawnId = 0;
m_lootRecipient = 0;
m_lootRecipientGroup = 0;
m_groupLootTimer = 0;
lootingGroupLowGUID = 0;
@@ -109,7 +107,7 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
void GameObject::RemoveFromOwner()
{
uint64 ownerGUID = GetOwnerGUID();
ObjectGuid ownerGUID = GetOwnerGUID();
if (!ownerGUID)
return;
@@ -120,16 +118,10 @@ void GameObject::RemoveFromOwner()
return;
}
// Xinef: not needed
/*const char * ownerType = "creature";
if (IS_PLAYER_GUID(ownerGUID))
ownerType = "player";
else if (IS_PET_GUID(ownerGUID))
ownerType = "pet";
LOG_FATAL("server", "Delete GameObject (%s Entry: %u SpellId %u LinkedGO %u) that lost references to owner %s GO list. Crash possible later.",
GetGUID().ToString().c_str(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
LOG_FATAL("server", "Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(ownerGUID), ownerType);*/
SetOwnerGUID(0);
SetOwnerGUID(ObjectGuid::Empty);
}
void GameObject::AddToWorld()
@@ -140,7 +132,9 @@ void GameObject::AddToWorld()
if (m_zoneScript)
m_zoneScript->OnGameObjectCreate(this);
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<GameObject>(GetGUID(), this);
if (m_spawnId)
GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
if (m_model)
{
@@ -169,13 +163,19 @@ void GameObject::RemoveFromWorld()
m_zoneScript->OnGameObjectRemove(this);
RemoveFromOwner();
if (m_model)
if (GetMap()->ContainsGameObjectModel(*m_model))
GetMap()->RemoveGameObjectModel(*m_model);
if (Transport* transport = GetTransport())
transport->RemovePassenger(this, true);
WorldObject::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
if (m_spawnId)
acore::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
GetMap()->GetObjectsStore().Remove<GameObject>(GetGUID());
}
}
@@ -183,13 +183,15 @@ void GameObject::CheckRitualList()
{
if (m_unique_users.empty())
return;
for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();)
for (GuidSet::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();)
{
if (*itr == GetOwnerGUID())
{
++itr;
continue;
}
bool erase = true;
if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr))
if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
@@ -208,9 +210,10 @@ void GameObject::ClearRitualList()
uint32 animSpell = GetGOInfo()->summoningRitual.animSpell;
if (!animSpell || m_unique_users.empty())
return;
for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end(); ++itr)
for (ObjectGuid const guid : m_unique_users)
{
if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr))
if (Player* channeler = ObjectAccessor::GetPlayer(*this, guid))
if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (spell->m_spellInfo->Id == animSpell)
{
@@ -218,10 +221,11 @@ void GameObject::ClearRitualList()
spell->finish();
}
}
m_unique_users.clear();
}
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
{
ASSERT(map);
SetMap(map);
@@ -251,7 +255,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
return false;
}
Object::_Create(guidlow, goinfo->entry, HIGHGUID_GAMEOBJECT);
Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject);
m_goInfo = goinfo;
@@ -431,7 +435,7 @@ void GameObject::Update(uint32 diff)
bool triggered = info->summoningRitual.animSpell;
Unit* owner = GetOwner();
Unit* spellCaster = owner ? owner : ObjectAccessor::GetPlayer(*this, MAKE_NEW_GUID(m_ritualOwnerGUIDLow, 0, HIGHGUID_PLAYER));
Unit* spellCaster = owner ? owner : ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID);
if (!spellCaster)
{
SetLootState(GO_JUST_DEACTIVATED);
@@ -493,11 +497,11 @@ void GameObject::Update(uint32 diff)
time_t now = time(nullptr);
if (m_respawnTime <= now) // timer expired
{
uint64 dbtableHighGuid = MAKE_NEW_GUID(m_DBTableGuid, GetEntry(), HIGHGUID_GAMEOBJECT);
ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::GameObject>(GetEntry(), m_spawnId);
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
if (linkedRespawntime) // Can't respawn, the master is dead
{
uint64 targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
@@ -552,9 +556,9 @@ void GameObject::Update(uint32 diff)
AI()->Reset();
// respawn timer
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
if (poolid)
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId);
else
GetMap()->AddToMap(this);
}
@@ -793,9 +797,9 @@ void GameObject::Delete()
if (GetGOInfo()->type == GAMEOBJECT_TYPE_SUMMONING_RITUAL)
ClearRitualList();
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
if (poolid)
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId);
else
AddObjectToRemoveList();
}
@@ -844,7 +848,7 @@ void GameObject::SaveToDB()
{
// this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise
GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid);
GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId);
if (!data)
{
LOG_ERROR("server", "GameObject::SaveToDB failed, cannot get gameobject data!");
@@ -861,12 +865,12 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
if (!goI)
return;
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
// update in loaded data (changing data only in this place)
GameObjectData& data = sObjectMgr->NewGOData(m_DBTableGuid);
if (!m_spawnId)
m_spawnId = sObjectMgr->GenerateGameObjectSpawnId();
// update in loaded data (changing data only in this place)
GameObjectData& data = sObjectMgr->NewGOData(m_spawnId);
// data->guid = guid must not be updated at save
data.id = GetEntry();
data.mapid = mapid;
data.phaseMask = phaseMask;
@@ -887,11 +891,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
uint8 index = 0;
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
@@ -912,13 +916,13 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
WorldDatabase.CommitTransaction(trans);
}
bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap)
{
GameObjectData const* data = sObjectMgr->GetGOData(guid);
GameObjectData const* data = sObjectMgr->GetGOData(spawnId);
if (!data)
{
LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", guid);
LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", spawnId);
return false;
}
@@ -934,10 +938,9 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
GOState go_state = data->go_state;
uint32 artKit = data->artKit;
m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
m_spawnId = spawnId;
if (!Create(guid, entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
return false;
if (data->spawntimesecs >= 0)
@@ -953,13 +956,13 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
else
{
m_respawnDelayTime = data->spawntimesecs;
m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid);
m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId);
// ready to respawn
if (m_respawnTime && m_respawnTime <= time(nullptr))
{
m_respawnTime = 0;
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
}
}
}
@@ -980,19 +983,15 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
void GameObject::DeleteFromDB()
{
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
sObjectMgr->DeleteGOData(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
sObjectMgr->DeleteGOData(m_spawnId);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
WorldDatabase.Execute(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
stmt->setUInt32(0, m_spawnId);
WorldDatabase.Execute(stmt);
}
@@ -1041,7 +1040,7 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime()
{
if (m_goData && m_goData->dbData && m_respawnTime > time(nullptr) && m_spawnedByDefault)
GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
GetMap()->SaveGORespawnTime(m_spawnId, m_respawnTime);
}
bool GameObject::IsNeverVisible() const
@@ -1067,7 +1066,7 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
return false;
// Always seen by owner and friendly units
if (uint64 guid = GetOwnerGUID())
if (ObjectGuid guid = GetOwnerGUID())
{
if (seer->GetGUID() == guid)
return true;
@@ -1100,7 +1099,7 @@ void GameObject::Respawn()
if (m_spawnedByDefault && m_respawnTime > 0)
{
m_respawnTime = time(nullptr);
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
GetMap()->RemoveGORespawnTime(m_spawnId);
}
}
@@ -1239,12 +1238,12 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
void GameObject::SetGoArtKit(uint8 kit)
{
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid));
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_spawnId));
if (data)
data->artKit = kit;
}
void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid)
void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid)
{
const GameObjectData* data = nullptr;
if (go)
@@ -1358,9 +1357,9 @@ void GameObject::Use(Unit* user)
{
if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
for (uint32 i = 0; i < info->chair.slots; ++i)
ChairListSlots[i] = 0; // Last user of current slot set to 0 (none sit here yet)
ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet)
else
ChairListSlots[0] = 0; // error in DB, make one default slot
ChairListSlots[0].Clear(); // error in DB, make one default slot
}
Player* player = user->ToPlayer();
@@ -1393,10 +1392,10 @@ void GameObject::Use(Unit* user)
if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required.
else
itr->second = 0; // This seat is unoccupied.
itr->second.Clear(); // This seat is unoccupied.
}
else
itr->second = 0; // The seat may of had an occupant, but they're offline.
itr->second.Clear(); // The seat may of had an occupant, but they're offline.
}
found_free_slot = true;
@@ -1455,7 +1454,7 @@ void GameObject::Use(Unit* user)
if (info->goober.eventId)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (spawnId %u).", info->goober.eventId, GetEntry(), m_spawnId);
#endif
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
EventInform(info->goober.eventId);
@@ -1617,8 +1616,8 @@ void GameObject::Use(Unit* user)
GameObjectTemplate const* info = GetGOInfo();
// ritual owner is set for GO's without owner (not summoned)
if (m_ritualOwnerGUIDLow == 0 && !owner)
m_ritualOwnerGUIDLow = player->GetGUIDLow();
if (!m_ritualOwnerGUID && !owner)
m_ritualOwnerGUID = player->GetGUID();
if (owner)
{
@@ -1635,7 +1634,7 @@ void GameObject::Use(Unit* user)
}
else
{
Player* ritualOwner = ObjectAccessor::GetPlayer(*this, MAKE_NEW_GUID(m_ritualOwnerGUIDLow, 0, HIGHGUID_PLAYER));
Player* ritualOwner = ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID);
if (!ritualOwner)
return;
if (player != ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(ritualOwner)))
@@ -1677,7 +1676,7 @@ void GameObject::Use(Unit* user)
if (info->spellcaster.partyOnly)
{
Player const* caster = ObjectAccessor::GetObjectInOrOutOfWorld(GetOwnerGUID(), (Player*)nullptr);
Player const* caster = ObjectAccessor::FindConnectedPlayer(GetOwnerGUID());
if (!caster || user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster))
return;
}
@@ -1839,8 +1838,8 @@ void GameObject::Use(Unit* user)
}
default:
if (GetGoType() >= MAX_GAMEOBJECT_TYPE)
LOG_ERROR("server", "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)",
user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType());
LOG_ERROR("server", "GameObject::Use(): unit (%s, name: %s) tries to use object (%s, name: %s) of unknown type (%u)",
user->GetGUID().ToString().c_str(), user->GetName().c_str(), GetGUID().ToString().c_str(), GetGOInfo()->name.c_str(), GetGoType());
break;
}
@@ -1924,7 +1923,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
// xinef: set proper orientation, fixes cast against stealthed targets
if (target)
trigger->SetInFront(target);
trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : 0);
trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : ObjectGuid::Empty);
}
}
@@ -2071,9 +2070,9 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= nullptr*/
if (player)
{
WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8 + 8 + 8 + 4 + 4);
data.appendPackGUID(GetGUID());
data.appendPackGUID(attackerOrHealer->GetGUID());
data.appendPackGUID(player->GetGUID());
data << GetPackGUID();
data << attackerOrHealer->GetPackGUID();
data << player->GetPackGUID();
data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event
// change >= 0 triggers SPELL_BUILDING_DAMAGE event
data << uint32(spellId);
@@ -2299,7 +2298,7 @@ Player* GameObject::GetLootRecipient() const
{
if (!m_lootRecipient)
return nullptr;
return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient);
return ObjectAccessor::FindConnectedPlayer(m_lootRecipient);
}
Group* GameObject::GetLootRecipientGroup() const
@@ -2317,7 +2316,7 @@ void GameObject::SetLootRecipient(Unit* unit)
if (!unit)
{
m_lootRecipient = 0;
m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
return;
}
@@ -2331,7 +2330,7 @@ void GameObject::SetLootRecipient(Unit* unit)
m_lootRecipient = player->GetGUID();
if (Group* group = player->GetGroup())
m_lootRecipientGroup = group->GetLowGUID();
m_lootRecipientGroup = group->GetGUID().GetCounter();
}
bool GameObject::IsLootAllowedFor(Player const* player) const
@@ -2449,9 +2448,9 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
void GameObject::GetRespawnPosition(float& x, float& y, float& z, float* ori /* = nullptr*/) const
{
if (m_DBTableGuid)
if (m_spawnId)
{
if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow()))
if (GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId))
{
x = data->posX;
y = data->posY;

View File

@@ -738,7 +738,7 @@ public:
void RemoveFromWorld() override;
void CleanupsBeforeDelete(bool finalCleanup = true) override;
virtual bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);
virtual bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0);
void Update(uint32 p_time) override;
[[nodiscard]] GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
[[nodiscard]] GameObjectTemplateAddon const* GetTemplateAddon() const;
@@ -748,7 +748,7 @@ public:
[[nodiscard]] bool IsTransport() const;
[[nodiscard]] bool IsDestructibleBuilding() const;
[[nodiscard]] uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
[[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
// z_rot, y_rot, x_rot - rotation angles around z, y and x axes
void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
@@ -761,11 +761,11 @@ public:
void SaveToDB();
void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
bool LoadFromDB(uint32 guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
bool LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap = true);
bool LoadFromDB(ObjectGuid::LowType guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true);
void DeleteFromDB();
void SetOwnerGUID(uint64 owner)
void SetOwnerGUID(ObjectGuid owner)
{
// Owner already found and different than expected owner - remove object from old owner
if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
@@ -773,9 +773,9 @@ public:
ABORT();
}
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
SetGuidValue(OBJECT_FIELD_CREATED_BY, owner);
}
[[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
[[nodiscard]] Unit* GetOwner() const;
void SetSpellId(uint32 id)
@@ -822,7 +822,7 @@ public:
void SetGoArtKit(uint8 artkit);
[[nodiscard]] uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0);
static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0);
void SetPhaseMask(uint32 newPhaseMask, bool update) override;
void EnableCollision(bool enable);
@@ -840,11 +840,11 @@ public:
void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
void ResetLootMode() { m_LootMode = LOOT_MODE_DEFAULT; }
void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
[[nodiscard]] bool IsInSkillupList(uint32 PlayerGuidLow) const
void AddToSkillupList(ObjectGuid playerGuid) { m_SkillupList.push_back(playerGuid); }
[[nodiscard]] bool IsInSkillupList(ObjectGuid playerGuid) const
{
for (unsigned int i : m_SkillupList)
if (i == PlayerGuidLow)
for (ObjectGuid const guid : m_SkillupList)
if (guid == playerGuid)
return true;
return false;
@@ -961,16 +961,16 @@ protected:
bool m_spawnedByDefault;
uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
// For traps this: spell casting cooldown, for doors/buttons: reset time.
std::list<uint32> m_SkillupList;
GuidList m_SkillupList;
uint32 m_ritualOwnerGUIDLow; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
std::set<uint64> m_unique_users;
ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
GuidSet m_unique_users;
uint32 m_usetimes;
typedef std::map<uint32, uint64> ChairSlotAndUser;
typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
ChairSlotAndUser ChairListSlots;
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
ObjectGuid::LowType m_spawnId; ///< For new or temporary gameobjects is 0 for saved it is lowguid
GameObjectTemplate const* m_goInfo;
GameObjectData const* m_goData;
GameObjectValue m_goValue;
@@ -980,7 +980,7 @@ protected:
G3D::Quat m_worldRotation;
Position m_stationaryPosition;
uint64 m_lootRecipient;
ObjectGuid m_lootRecipient;
uint32 m_lootRecipientGroup;
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
uint32 m_lootGenerationTime;

View File

@@ -56,20 +56,20 @@ void Bag::RemoveFromWorld()
Item::RemoveFromWorld();
}
bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
bool Bag::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner)
{
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
return false;
Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
Object::_Create(guidlow, 0, HighGuid::Item);
SetEntry(itemid);
SetObjectScale(1.0f);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
@@ -81,7 +81,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
// Cleaning 20 slots
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty);
m_bagslot[i] = nullptr;
}
@@ -93,7 +93,7 @@ void Bag::SaveToDB(SQLTransaction& trans)
Item::SaveToDB(trans);
}
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
bool Bag::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
{
if (!Item::LoadFromDB(guid, owner_guid, fields, entry))
return false;
@@ -103,7 +103,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
{
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty);
delete m_bagslot[i];
m_bagslot[i] = nullptr;
}
@@ -138,7 +138,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/)
m_bagslot[slot]->SetContainer(nullptr);
m_bagslot[slot] = nullptr;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), 0);
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid::Empty);
}
void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
@@ -148,9 +148,9 @@ void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
if (pItem && pItem->GetGUID() != this->GetGUID())
{
m_bagslot[slot] = pItem;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetOwnerGUID());
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetOwnerGUID());
pItem->SetContainer(this);
pItem->SetSlot(slot);
}
@@ -212,7 +212,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem)
return count;
}
uint8 Bag::GetSlotByItemGUID(uint64 guid) const
uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
{
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] != 0)

View File

@@ -22,7 +22,7 @@ public:
void AddToWorld() override;
void RemoveFromWorld() override;
bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override;
bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) override;
void Clear();
void StoreItem(uint8 slot, Item* pItem, bool update);
@@ -32,7 +32,7 @@ public:
uint32 GetItemCount(uint32 item, Item* eItem = nullptr) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
[[nodiscard]] uint8 GetSlotByItemGUID(uint64 guid) const;
[[nodiscard]] uint8 GetSlotByItemGUID(ObjectGuid guid) const;
[[nodiscard]] bool IsEmpty() const;
[[nodiscard]] uint32 GetFreeSlots() const;
[[nodiscard]] uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
@@ -41,7 +41,7 @@ public:
// overwrite virtual Item::SaveToDB
void SaveToDB(SQLTransaction& trans) override;
// overwrite virtual Item::LoadFromDB
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) override;
bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override;
// overwrite virtual Item::DeleteFromDB
void DeleteFromDB(SQLTransaction& trans) override;

View File

@@ -247,15 +247,15 @@ Item::Item()
m_paidExtendedCost = 0;
}
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner)
{
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
Object::_Create(guidlow, 0, HighGuid::Item);
SetEntry(itemid);
SetObjectScale(1.0f);
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
if (!itemProto)
@@ -309,7 +309,7 @@ void Item::SaveToDB(SQLTransaction& trans)
if (!isInTransaction)
trans = CharacterDatabase.BeginTransaction();
uint32 guid = GetGUIDLow();
ObjectGuid::LowType guid = GetGUID().GetCounter();
switch (uState)
{
case ITEM_NEW:
@@ -318,9 +318,9 @@ void Item::SaveToDB(SQLTransaction& trans)
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
stmt->setUInt32( index, GetEntry());
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
stmt->setUInt32(++index, GetOwnerGUID().GetCounter());
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
stmt->setUInt32(++index, GetCount());
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
@@ -351,7 +351,7 @@ void Item::SaveToDB(SQLTransaction& trans)
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
stmt->setUInt32(1, guid);
trans->Append(stmt);
}
@@ -386,14 +386,14 @@ void Item::SaveToDB(SQLTransaction& trans)
CharacterDatabase.CommitTransaction(trans);
}
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
{
// 0 1 2 3 4 5 6 7 8 9 10
//result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
// create item before any checks for store correct guid
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
Object::_Create(guid, 0, HIGHGUID_ITEM);
Object::_Create(guid, 0, HighGuid::Item);
// Set entry, MUST be before proto check
SetEntry(entry);
@@ -404,12 +404,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
return false;
// set owner (not if item is only loaded for gbank/auction/mail
if (owner_guid != 0)
if (owner_guid)
SetOwnerGUID(owner_guid);
bool need_save = false; // need explicit save data at load fixes
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
SetUInt64Value(ITEM_FIELD_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()));
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()));
SetCount(fields[2].GetUInt32());
uint32 duration = fields[3].GetUInt32();
@@ -470,7 +470,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
}
/*static*/
void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid)
{
sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
@@ -480,11 +480,11 @@ void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromDB(SQLTransaction& trans)
{
DeleteFromDB(trans, GetGUIDLow());
DeleteFromDB(trans, GetGUID().GetCounter());
}
/*static*/
void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
stmt->setUInt32(0, itemGuid);
@@ -493,7 +493,7 @@ void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid)
void Item::DeleteFromInventoryDB(SQLTransaction& trans)
{
DeleteFromInventoryDB(trans, GetGUIDLow());
DeleteFromInventoryDB(trans, GetGUID().GetCounter());
}
ItemTemplate const* Item::GetTemplate() const
@@ -674,7 +674,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
if (forplayer)
{
RemoveFromUpdateQueueOf(forplayer);
forplayer->DeleteRefundReference(GetGUIDLow());
forplayer->DeleteRefundReference(GetGUID());
}
delete this;
return;
@@ -706,7 +706,7 @@ void Item::AddToUpdateQueueOf(Player* player)
if (player->GetGUID() != GetOwnerGUID())
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
#endif
return;
}
@@ -728,7 +728,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
if (player->GetGUID() != GetOwnerGUID())
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
#endif
return;
}
@@ -880,7 +880,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
return true;
}
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/)
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster /*= ObjectGuid::Empty*/)
{
// Better lost small time at check in comparison lost time at item save to DB.
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
@@ -890,7 +890,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
{
if (uint32 oldEnchant = GetEnchantmentId(slot))
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetEntry(), oldEnchant);
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant);
if (id)
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
@@ -1025,7 +1025,7 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
void Item::SendUpdateSockets()
{
WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4);
data << uint64(GetGUID());
data << GetGUID();
for (uint32 i = SOCK_ENCHANTMENT_SLOT; i <= BONUS_ENCHANTMENT_SLOT; ++i)
data << uint32(GetEnchantmentId(EnchantmentSlot(i)));
@@ -1042,7 +1042,7 @@ void Item::SendTimeUpdate(Player* owner)
return;
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
data << uint64(GetGUID());
data << GetGUID();
data << uint32(duration);
owner->GetSession()->SendPacket(&data);
}
@@ -1061,7 +1061,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
Item* pItem = NewItemOrBag(pProto);
if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player))
if (pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), item, player))
{
pItem->SetCount(count);
if (!clone)
@@ -1103,7 +1103,7 @@ bool Item::IsBindedNotWith(Player const* player) const
return false;
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
if (allowedGUIDs.find(player->GetGUIDLow()) != allowedGUIDs.end())
if (allowedGUIDs.find(player->GetGUID()) != allowedGUIDs.end())
return false;
// BOA item case
@@ -1120,16 +1120,28 @@ void Item::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&)
ClearUpdateMask(false);
}
void Item::AddToObjectUpdate()
{
if (Player* owner = GetOwner())
owner->GetMap()->AddUpdateObject(this);
}
void Item::RemoveFromObjectUpdate()
{
if (Player* owner = GetOwner())
owner->GetMap()->RemoveUpdateObject(this);
}
void Item::SaveRefundDataToDB()
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
stmt->setUInt32(1, GetRefundRecipient());
stmt->setUInt32(2, GetPaidMoney());
stmt->setUInt16(3, uint16(GetPaidExtendedCost()));
@@ -1143,7 +1155,7 @@ void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
if (trans)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
(*trans)->Append(stmt);
}
}
@@ -1163,7 +1175,7 @@ void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransa
SetPaidExtendedCost(0);
DeleteRefundDataFromDB(trans);
owner->DeleteRefundReference(GetGUIDLow());
owner->DeleteRefundReference(GetGUID());
}
void Item::UpdatePlayedTime(Player* owner)
@@ -1221,7 +1233,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
allowedGUIDs.clear();
SetState(ITEM_CHANGED, currentOwner);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(0, GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}

View File

@@ -204,12 +204,12 @@ public:
Item();
virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner);
[[nodiscard]] ItemTemplate const* GetTemplate() const;
[[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(ITEM_FIELD_OWNER); }
void SetOwnerGUID(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
[[nodiscard]] Player* GetOwner() const;
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); }
@@ -219,10 +219,10 @@ public:
[[nodiscard]] bool IsBoundByEnchant() const;
[[nodiscard]] bool IsBoundByTempEnchant() const;
virtual void SaveToDB(SQLTransaction& trans);
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid);
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry);
static void DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid);
virtual void DeleteFromDB(SQLTransaction& trans);
static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid);
static void DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid);
void DeleteFromInventoryDB(SQLTransaction& trans);
void SaveRefundDataToDB();
void DeleteRefundDataFromDB(SQLTransaction* trans);
@@ -274,7 +274,7 @@ public:
void SetItemRandomProperties(int32 randomPropId);
void UpdateItemSuffixFactor();
static int32 GenerateItemRandomPropertyId(uint32 item_id);
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0);
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster = ObjectGuid::Empty);
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
void ClearEnchantment(EnchantmentSlot slot);
@@ -318,10 +318,10 @@ public:
// Item Refund system
void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = nullptr);
void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; }
void SetRefundRecipient(ObjectGuid::LowType pGuidLow) { m_refundRecipient = pGuidLow; }
void SetPaidMoney(uint32 money) { m_paidMoney = money; }
void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; }
uint32 GetRefundRecipient() { return m_refundRecipient; }
ObjectGuid::LowType GetRefundRecipient() { return m_refundRecipient; }
uint32 GetPaidMoney() { return m_paidMoney; }
uint32 GetPaidExtendedCost() { return m_paidExtendedCost; }
@@ -335,6 +335,8 @@ public:
bool CheckSoulboundTradeExpire();
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override;
void AddToObjectUpdate() override;
void RemoveFromObjectUpdate() override;
[[nodiscard]] uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
private:

View File

@@ -47,33 +47,6 @@
#include "LuaEngine.h"
#endif
uint32 GuidHigh2TypeId(uint32 guid_hi)
{
switch (guid_hi)
{
case HIGHGUID_ITEM:
return TYPEID_ITEM;
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER == HIGHGUID_ITEM currently
case HIGHGUID_UNIT:
return TYPEID_UNIT;
case HIGHGUID_PET:
return TYPEID_UNIT;
case HIGHGUID_PLAYER:
return TYPEID_PLAYER;
case HIGHGUID_GAMEOBJECT:
return TYPEID_GAMEOBJECT;
case HIGHGUID_DYNAMICOBJECT:
return TYPEID_DYNAMICOBJECT;
case HIGHGUID_CORPSE:
return TYPEID_CORPSE;
case HIGHGUID_MO_TRANSPORT:
return TYPEID_GAMEOBJECT;
case HIGHGUID_VEHICLE:
return TYPEID_UNIT;
}
return NUM_CLIENT_OBJECT_TYPES; // unknown
}
Object::Object() : m_PackGUID(sizeof(uint64) + 1)
{
m_objectTypeId = TYPEID_OBJECT;
@@ -86,8 +59,6 @@ Object::Object() : m_PackGUID(sizeof(uint64) + 1)
m_inWorld = false;
m_objectUpdated = false;
m_PackGUID.appendPackGUID(0);
sScriptMgr->OnConstructObject(this);
}
@@ -103,7 +74,7 @@ WorldObject::~WorldObject()
{
if (GetTypeId() == TYPEID_CORPSE)
{
LOG_FATAL("server", "Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry());
LOG_FATAL("server", "Object::~Object Corpse %s, type=%d deleted but still in map!!", GetGUID().ToString().c_str(), ((Corpse*)this)->GetType());
ABORT();
}
ResetMap();
@@ -116,18 +87,16 @@ Object::~Object()
if (IsInWorld())
{
LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry());
LOG_FATAL("server", "Object::~Object - %s deleted but still in world!!", GetGUID().ToString().c_str());
if (isType(TYPEMASK_ITEM))
LOG_FATAL("server", "Item slot %u", ((Item*)this)->GetSlot());
ABORT();
RemoveFromWorld();
}
if (m_objectUpdated)
{
LOG_FATAL("server", "Object::~Object - guid=" UI64FMTD ", typeid=%d, entry=%u deleted but still in update list!!", GetGUID(), GetTypeId(), GetEntry());
LOG_FATAL("server", "Object::~Object - %s deleted but still in update list!!", GetGUID().ToString().c_str());
ABORT();
sObjectAccessor->RemoveUpdateObject(this);
}
delete [] m_uint32Values;
@@ -144,15 +113,14 @@ void Object::_InitValues()
m_objectUpdated = false;
}
void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
void Object::_Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
{
if (!m_uint32Values) _InitValues();
uint64 guid = MAKE_NEW_GUID(guidlow, entry, guidhigh);
SetUInt64Value(OBJECT_FIELD_GUID, guid);
ObjectGuid guid(guidhigh, entry, guidlow);
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetUInt32Value(OBJECT_FIELD_TYPE, m_objectType);
m_PackGUID.wpos(0);
m_PackGUID.appendPackGUID(GetGUID());
m_PackGUID.Set(guid);
}
std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const
@@ -173,7 +141,8 @@ void Object::AddToWorld()
m_inWorld = true;
// synchronize values mirror with values array (changes will send in updatecreate opcode any way
ClearUpdateMask(true);
ASSERT(!m_objectUpdated);
ClearUpdateMask(false);
}
void Object::RemoveFromWorld()
@@ -192,7 +161,7 @@ void Object::BuildMovementUpdateBlock(UpdateData* data, uint32 flags) const
ByteBuffer buf(500);
buf << uint8(UPDATETYPE_MOVEMENT);
buf.append(GetPackGUID());
buf << GetPackGUID();
BuildMovementUpdate(&buf, flags);
@@ -248,7 +217,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(500);
buf << (uint8)updatetype;
buf.append(GetPackGUID());
buf << GetPackGUID();
buf << (uint8)m_objectTypeId;
BuildMovementUpdate(&buf, flags);
@@ -272,7 +241,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(500);
buf << (uint8) UPDATETYPE_VALUES;
buf.append(GetPackGUID());
buf << GetPackGUID();
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target);
@@ -295,14 +264,14 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
if (bg->isArena())
{
WorldPacket data(SMSG_ARENA_UNIT_DESTROYED, 8);
data << uint64(GetGUID());
data << GetGUID();
target->GetSession()->SendPacket(&data);
}
}
}
WorldPacket data(SMSG_DESTROY_OBJECT, 8 + 1);
data << uint64(GetGUID());
data << GetGUID();
//! If the following bool is true, the client will call "void CGUnit_C::OnDeath()" for this object.
//! OnDeath() does for eg trigger death animation and interrupts certain spells/missiles/auras/sounds...
data << uint8(onDeath ? 1 : 0);
@@ -353,7 +322,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
Transport* transport = object->GetTransport();
if (transport)
data->append(transport->GetPackGUID());
*data << transport->GetPackGUID();
else
*data << uint8(0);
@@ -411,7 +380,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
case TYPEID_GAMEOBJECT:
case TYPEID_DYNAMICOBJECT:
case TYPEID_CORPSE:
*data << uint32(GetGUIDLow()); // GetGUIDLow()
*data << uint32(GetGUID().GetCounter());
break;
//! Unit, Player and default here are sending wrong values.
/// @todo Research the proper formula
@@ -434,7 +403,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_HAS_TARGET)
{
if (Unit* victim = unit->GetVictim())
data->append(victim->GetPackGUID());
*data << victim->GetPackGUID();
else
*data << uint8(0);
}
@@ -492,6 +461,15 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe
data->append(fieldBuffer);
}
void Object::AddToObjectUpdateIfNeeded()
{
if (m_inWorld && !m_objectUpdated)
{
AddToObjectUpdate();
m_objectUpdated = true;
}
}
void Object::ClearUpdateMask(bool remove)
{
_changesMask.Clear();
@@ -499,7 +477,7 @@ void Object::ClearUpdateMask(bool remove)
if (m_objectUpdated)
{
if (remove)
sObjectAccessor->RemoveUpdateObject(this);
RemoveFromObjectUpdate();
m_objectUpdated = false;
}
}
@@ -597,11 +575,7 @@ void Object::SetInt32Value(uint16 index, int32 value)
m_int32Values[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -614,11 +588,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
m_uint32Values[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -633,6 +603,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value)
void Object::SetUInt64Value(uint16 index, uint64 value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (*((uint64*) & (m_uint32Values[index])) != value)
{
m_uint32Values[index] = PAIR64_LOPART(value);
@@ -640,29 +611,21 @@ void Object::SetUInt64Value(uint16 index, uint64 value)
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
bool Object::AddUInt64Value(uint16 index, uint64 value)
bool Object::AddGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (value && !*((uint64*) & (m_uint32Values[index])))
if (value && !*((ObjectGuid*)&(m_uint32Values[index])))
{
m_uint32Values[index] = PAIR64_LOPART(value);
m_uint32Values[index + 1] = PAIR64_HIPART(value);
*((ObjectGuid*)&(m_uint32Values[index])) = value;
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -670,21 +633,18 @@ bool Object::AddUInt64Value(uint16 index, uint64 value)
return false;
}
bool Object::RemoveUInt64Value(uint16 index, uint64 value)
bool Object::RemoveGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (value && *((uint64*) & (m_uint32Values[index])) == value)
if (value && *((ObjectGuid*)&(m_uint32Values[index])) == value)
{
m_uint32Values[index] = 0;
m_uint32Values[index + 1] = 0;
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
return true;
}
@@ -692,6 +652,20 @@ bool Object::RemoveUInt64Value(uint16 index, uint64 value)
return false;
}
void Object::SetGuidValue(uint16 index, ObjectGuid value)
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if (*((ObjectGuid*)&(m_uint32Values[index])) != value)
{
*((ObjectGuid*)&(m_uint32Values[index])) = value;
_changesMask.SetBit(index);
_changesMask.SetBit(index + 1);
AddToObjectUpdateIfNeeded();
}
}
void Object::SetFloatValue(uint16 index, float value)
{
ASSERT(index < m_valuesCount || PrintIndexError(index, true));
@@ -701,11 +675,7 @@ void Object::SetFloatValue(uint16 index, float value)
m_floatValues[index] = value;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -725,11 +695,7 @@ void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
m_uint32Values[index] |= uint32(uint32(value) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -749,11 +715,7 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
m_uint32Values[index] |= uint32(uint32(value) << (offset * 16));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -816,11 +778,7 @@ void Object::SetFlag(uint16 index, uint32 newFlag)
m_uint32Values[index] = newval;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -837,11 +795,7 @@ void Object::RemoveFlag(uint16 index, uint32 oldFlag)
m_uint32Values[index] = newval;
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -860,11 +814,7 @@ void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
m_uint32Values[index] |= uint32(uint32(newFlag) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -883,11 +833,7 @@ void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
m_uint32Values[index] &= ~uint32(uint32(oldFlag) << (offset * 8));
_changesMask.SetBit(index);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
}
@@ -966,7 +912,7 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
void MovementInfo::OutDebug()
{
LOG_INFO("server", "MOVEMENT INFO");
LOG_INFO("server", "guid " UI64FMTD, guid);
LOG_INFO("server", "guid %s", guid.ToString().c_str());
LOG_INFO("server", "flags %u", flags);
LOG_INFO("server", "flags2 %u", flags2);
LOG_INFO("server", "time %u current time " UI64FMTD "", flags2, uint64(::time(nullptr)));
@@ -974,7 +920,7 @@ void MovementInfo::OutDebug()
if (flags & MOVEMENTFLAG_ONTRANSPORT)
{
LOG_INFO("server", "TRANSPORT:");
LOG_INFO("server", "guid: " UI64FMTD, transport.guid);
LOG_INFO("server", "guid: %s", transport.guid.ToString().c_str());
LOG_INFO("server", "position: `%s`", transport.pos.ToString().c_str());
LOG_INFO("server", "seat: %i", transport.seat);
LOG_INFO("server", "time: %u", transport.time);
@@ -1082,7 +1028,7 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
RemoveFromWorld();
}
void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
void WorldObject::_Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
{
Object::_Create(guidlow, 0, guidhigh);
SetPhaseMask(phaseMask, false);
@@ -1122,7 +1068,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
float sizefactor = GetObjectSize() + obj->GetObjectSize();
float maxdist = dist2compare + sizefactor;
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUIDLow() == m_transport->GetGUIDLow())
if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUID() == m_transport->GetGUID())
{
float dtx = m_movementInfo.transport.pos.m_positionX - obj->m_movementInfo.transport.pos.m_positionX;
float dty = m_movementInfo.transport.pos.m_positionY - obj->m_movementInfo.transport.pos.m_positionY;
@@ -1951,11 +1897,7 @@ void WorldObject::SendPlayMusic(uint32 Music, bool OnlySelf)
void Object::ForceValuesUpdateAtIndex(uint32 i)
{
_changesMask.SetBit(i);
if (m_inWorld && !m_objectUpdated)
{
sObjectAccessor->AddUpdateObject(this);
m_objectUpdated = true;
}
AddToObjectUpdateIfNeeded();
}
namespace acore
@@ -2120,7 +2062,7 @@ void WorldObject::MonsterWhisper(int32 textId, Player const* target, bool IsBoss
void Unit::BuildHeartBeatMsg(WorldPacket* data) const
{
data->Initialize(MSG_MOVE_HEARTBEAT, 32);
data->append(GetPackGUID());
*data << GetPackGUID();
BuildMovementPacket(data);
}
@@ -2134,17 +2076,17 @@ void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*
VisitNearbyWorldObject(dist, notifier);
}
void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid)
{
WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8);
data << uint64(guid);
data << guid;
SendMessageToSet(&data, true);
}
void WorldObject::SetMap(Map* map)
{
ASSERT(map);
ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE);
ASSERT(!IsInWorld());
if (m_currMap == map) // command add npc: first create, than loadfromdb
return;
if (m_currMap)
@@ -2197,7 +2139,7 @@ void WorldObject::AddObjectToRemoveList()
Map* map = FindMap();
if (!map)
{
LOG_ERROR("server", "Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list not have valid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
LOG_ERROR("server", "Object %s at attempt add to move list not have valid map (Id: %u).", GetGUID().ToString().c_str(), GetMapId());
return;
}
@@ -2263,26 +2205,26 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
switch (mask)
{
case UNIT_MASK_SUMMON:
summon = new TempSummon(properties, summoner ? summoner->GetGUID() : 0, false);
summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
break;
case UNIT_MASK_GUARDIAN:
summon = new Guardian(properties, summoner ? summoner->GetGUID() : 0, false);
summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
break;
case UNIT_MASK_PUPPET:
summon = new Puppet(properties, summoner ? summoner->GetGUID() : 0);
summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
break;
case UNIT_MASK_TOTEM:
summon = new Totem(properties, summoner ? summoner->GetGUID() : 0);
summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
break;
case UNIT_MASK_MINION:
summon = new Minion(properties, summoner ? summoner->GetGUID() : 0, false);
summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
break;
default:
return nullptr;
}
EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
{
delete summon;
return nullptr;
@@ -2293,7 +2235,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon->SetHomePosition(pos);
summon->InitStats(duration);
AddToMap(summon->ToCreature(), (IS_PLAYER_GUID(summon->GetOwnerGUID()) || (summoner && summoner->GetTransport())));
AddToMap(summon->ToCreature(), summon->GetOwnerGUID().IsPlayer() || (summoner && summoner->GetTransport()));
summon->InitSummon();
//ObjectAccessor::UpdateObjectVisibility(summon);
@@ -2330,7 +2272,7 @@ GameObject* Map::SummonGameObject(uint32 entry, float x, float y, float z, float
}
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
{
delete go;
return nullptr;
@@ -2363,6 +2305,11 @@ void WorldObject::SetZoneScript()
}
}
void WorldObject::ClearZoneScript()
{
m_zoneScript = nullptr;
}
TempSummon* WorldObject::SummonCreature(uint32 entry, const Position& pos, TempSummonType spwtype, uint32 duration, uint32 /*vehId*/, SummonPropertiesEntry const* properties) const
{
if (Map* map = FindMap())
@@ -2391,7 +2338,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
Map* map = GetMap();
GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
if (!go->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, GetPhaseMask(), x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
{
delete go;
return nullptr;
@@ -2857,7 +2804,7 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= nullptr*
{
WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
data << uint32(sound_id);
data << uint64(GetGUID());
data << GetGUID();
if (target)
target->SendDirectMessage(&data);
else
@@ -2996,13 +2943,13 @@ struct WorldObjectChangeAccumulator
for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{
source = iter->GetSource();
uint64 guid = source->GetCasterGUID();
ObjectGuid guid = source->GetCasterGUID();
if (IS_PLAYER_GUID(guid))
if (guid)
{
//Caster may be nullptr if DynObj is in removelist
if (Player* caster = ObjectAccessor::FindPlayer(guid))
if (caster->GetUInt64Value(PLAYER_FARSIGHT) == source->GetGUID())
if (caster->GetGuidValue(PLAYER_FARSIGHT) == source->GetGUID())
BuildPacket(caster);
}
}
@@ -3011,10 +2958,10 @@ struct WorldObjectChangeAccumulator
void BuildPacket(Player* player)
{
// Only send update once to a player
if (i_playerSet.find(player->GetGUIDLow()) == i_playerSet.end() && player->HaveAtClient(&i_object))
if (i_playerSet.find(player->GetGUID()) == i_playerSet.end() && player->HaveAtClient(&i_object))
{
i_object.BuildFieldsUpdate(player, i_updateDatas);
i_playerSet.insert(player->GetGUIDLow());
i_playerSet.insert(player->GetGUID());
}
}
@@ -3051,11 +2998,22 @@ void WorldObject::GetCreaturesWithEntryInRange(std::list<Creature*>& creatureLis
cell.Visit(pair, grid_visitor, *(this->GetMap()), *this, radius);
}
uint64 WorldObject::GetTransGUID() const
void WorldObject::AddToObjectUpdate()
{
GetMap()->AddUpdateObject(this);
}
void WorldObject::RemoveFromObjectUpdate()
{
GetMap()->RemoveUpdateObject(this);
}
ObjectGuid WorldObject::GetTransGUID() const
{
if (GetTransport())
return GetTransport()->GetGUID();
return 0;
return ObjectGuid::Empty;
}
float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const

View File

@@ -13,6 +13,7 @@
#include "GridReference.h"
#include "Map.h"
#include "ObjectDefines.h"
#include "ObjectGuid.h"
#include "UpdateData.h"
#include "UpdateMask.h"
#include <set>
@@ -23,35 +24,6 @@
class ElunaEventProcessor;
#endif
enum TypeMask
{
TYPEMASK_OBJECT = 0x0001,
TYPEMASK_ITEM = 0x0002,
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
TYPEMASK_UNIT = 0x0008, // creature
TYPEMASK_PLAYER = 0x0010,
TYPEMASK_GAMEOBJECT = 0x0020,
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum TypeID
{
TYPEID_OBJECT = 0,
TYPEID_ITEM = 1,
TYPEID_CONTAINER = 2,
TYPEID_UNIT = 3,
TYPEID_PLAYER = 4,
TYPEID_GAMEOBJECT = 5,
TYPEID_DYNAMICOBJECT = 6,
TYPEID_CORPSE = 7
};
#define NUM_CLIENT_OBJECT_TYPES 8
uint32 GuidHigh2TypeId(uint32 guid_hi);
enum TempSummonType
{
TEMPSUMMON_TIMED_OR_DEAD_DESPAWN = 1, // despawns after a specified time OR when the creature disappears
@@ -97,7 +69,7 @@ class StaticTransport;
class MotionTransport;
typedef std::unordered_map<Player*, UpdateData> UpdateDataMapType;
typedef std::unordered_set<uint32> UpdatePlayerSet;
typedef GuidUnorderedSet UpdatePlayerSet;
class Object
{
@@ -109,11 +81,9 @@ public:
virtual void AddToWorld();
virtual void RemoveFromWorld();
[[nodiscard]] uint64 GetGUID() const { return GetUInt64Value(0); }
[[nodiscard]] uint32 GetGUIDLow() const { return GUID_LOPART(GetUInt64Value(0)); }
[[nodiscard]] uint32 GetGUIDMid() const { return GUID_ENPART(GetUInt64Value(0)); }
[[nodiscard]] uint32 GetGUIDHigh() const { return GUID_HIPART(GetUInt64Value(0)); }
[[nodiscard]] const ByteBuffer& GetPackGUID() const { return m_PackGUID; }
[[nodiscard]] static ObjectGuid GetGUID(Object const* o) { return o ? o->GetGUID() : ObjectGuid::Empty; }
[[nodiscard]] ObjectGuid GetGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); }
[[nodiscard]] PackedGuid const& GetPackGUID() const { return m_PackGUID; }
[[nodiscard]] uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); }
@@ -170,6 +140,12 @@ public:
return *(((uint16*)&m_uint32Values[index]) + offset);
}
[[nodiscard]] ObjectGuid GetGuidValue(uint16 index) const
{
ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false));
return *((ObjectGuid*)&(m_uint32Values[index]));
}
void SetInt32Value(uint16 index, int32 value);
void SetUInt32Value(uint16 index, uint32 value);
void UpdateUInt32Value(uint16 index, uint32 value);
@@ -178,11 +154,12 @@ public:
void SetByteValue(uint16 index, uint8 offset, uint8 value);
void SetUInt16Value(uint16 index, uint8 offset, uint16 value);
void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); }
void SetGuidValue(uint16 index, ObjectGuid value);
void SetStatFloatValue(uint16 index, float value);
void SetStatInt32Value(uint16 index, int32 value);
bool AddUInt64Value(uint16 index, uint64 value);
bool RemoveUInt64Value(uint16 index, uint64 value);
bool AddGuidValue(uint16 index, ObjectGuid value);
bool RemoveGuidValue(uint16 index, ObjectGuid value);
void ApplyModUInt32Value(uint16 index, int32 val, bool apply);
void ApplyModInt32Value(uint16 index, int32 val, bool apply);
@@ -311,7 +288,7 @@ protected:
Object();
void _InitValues();
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh);
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh);
[[nodiscard]] std::string _ConcatFields(uint16 startIndex, uint16 size) const;
void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count);
@@ -338,12 +315,16 @@ protected:
uint16 _fieldNotifyFlags;
virtual void AddToObjectUpdate() = 0;
virtual void RemoveFromObjectUpdate() = 0;
void AddToObjectUpdateIfNeeded();
bool m_objectUpdated;
private:
bool m_inWorld;
ByteBuffer m_PackGUID;
PackedGuid m_PackGUID;
// for output helpfull error messages from asserts
[[nodiscard]] bool PrintIndexError(uint32 index, bool set) const;
@@ -586,7 +567,7 @@ ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYZOStreamer const&
struct MovementInfo
{
// common
uint64 guid{0};
ObjectGuid guid;
uint32 flags{0};
uint16 flags2{0};
Position pos;
@@ -597,14 +578,14 @@ struct MovementInfo
{
void Reset()
{
guid = 0;
guid.Clear();
pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
seat = -1;
time = 0;
time2 = 0;
}
uint64 guid;
ObjectGuid guid;
Position pos;
int8 seat;
uint32 time;
@@ -674,6 +655,12 @@ public:
Relocate(loc);
}
void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f)
{
m_mapId = mapId;
Relocate(x, y, z, o);
}
[[nodiscard]] uint32 GetMapId() const
{
return m_mapId;
@@ -758,7 +745,7 @@ public:
#else
virtual void Update(uint32 /*time_diff*/) { };
#endif
void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
void _Create(ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask);
void RemoveFromWorld() override
{
@@ -928,7 +915,7 @@ public:
void PlayDirectSound(uint32 sound_id, Player* target = nullptr);
void PlayDirectMusic(uint32 music_id, Player* target = nullptr);
void SendObjectDeSpawnAnim(uint64 guid);
void SendObjectDeSpawnAnim(ObjectGuid guid);
virtual void SaveRespawnTime() {}
void AddObjectToRemoveList();
@@ -962,6 +949,7 @@ public:
[[nodiscard]] Map const* GetBaseMap() const;
void SetZoneScript();
void ClearZoneScript();
[[nodiscard]] ZoneScript* GetZoneScript() const { return m_zoneScript; }
TempSummon* SummonCreature(uint32 id, const Position& pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0, SummonPropertiesEntry const* properties = nullptr) const;
@@ -993,6 +981,9 @@ public:
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet& player_set) override;
void GetCreaturesWithEntryInRange(std::list<Creature*>& creatureList, float radius, uint32 entry);
void AddToObjectUpdate() override;
void RemoveFromObjectUpdate() override;
//relocation and visibility system functions
void AddToNotify(uint16 f);
void RemoveFromNotify(uint16 f) { m_notifyflags &= ~f; }
@@ -1037,7 +1028,7 @@ public:
[[nodiscard]] float GetTransOffsetO() const { return m_movementInfo.transport.pos.GetOrientation(); }
[[nodiscard]] uint32 GetTransTime() const { return m_movementInfo.transport.time; }
[[nodiscard]] int8 GetTransSeat() const { return m_movementInfo.transport.seat; }
[[nodiscard]] virtual uint64 GetTransGUID() const;
[[nodiscard]] virtual ObjectGuid GetTransGUID() const;
void SetTransport(Transport* t) { m_transport = t; }
MovementInfo m_movementInfo;

View File

@@ -30,25 +30,7 @@
#define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players
#define DEFAULT_COLLISION_HEIGHT 2.03128f // Most common value in dbc
enum HighGuid
{
HIGHGUID_ITEM = 0x4000, // blizz 4000
HIGHGUID_CONTAINER = 0x4000, // blizz 4000
HIGHGUID_PLAYER = 0x0000, // blizz 0000
HIGHGUID_GAMEOBJECT = 0xF110, // blizz F110
HIGHGUID_TRANSPORT = 0xF120, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
HIGHGUID_UNIT = 0xF130, // blizz F130
HIGHGUID_PET = 0xF140, // blizz F140
HIGHGUID_VEHICLE = 0xF150, // blizz F550
HIGHGUID_DYNAMICOBJECT = 0xF100, // blizz F100
HIGHGUID_CORPSE = 0xF101, // blizz F100
HIGHGUID_MO_TRANSPORT = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
HIGHGUID_GROUP = 0x1F50,
HIGHGUID_INSTANCE = 0x1F42, // blizz 1F42/1F44/1F44/1F47
};
// used for creating values for respawn for example
inline uint64 MAKE_PAIR64(uint32 l, uint32 h);
inline uint32 PAIR64_HIPART(uint64 x);
inline uint32 PAIR64_LOPART(uint64 x);
inline uint16 MAKE_PAIR16(uint8 l, uint8 h);
@@ -56,40 +38,6 @@ inline uint32 MAKE_PAIR32(uint16 l, uint16 h);
inline uint16 PAIR32_HIPART(uint32 x);
inline uint16 PAIR32_LOPART(uint32 x);
inline bool IS_EMPTY_GUID(uint64 guid);
inline bool IS_CREATURE_GUID(uint64 guid);
inline bool IS_PET_GUID(uint64 guid);
inline bool IS_VEHICLE_GUID(uint64 guid);
inline bool IS_CRE_OR_VEH_GUID(uint64 guid);
inline bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid);
inline bool IS_PLAYER_GUID(uint64 guid);
inline bool IS_UNIT_GUID(uint64 guid);
inline bool IS_ITEM_GUID(uint64 guid);
inline bool IS_GAMEOBJECT_GUID(uint64 guid);
inline bool IS_DYNAMICOBJECT_GUID(uint64 guid);
inline bool IS_CORPSE_GUID(uint64 guid);
inline bool IS_TRANSPORT_GUID(uint64 guid);
inline bool IS_MO_TRANSPORT_GUID(uint64 guid);
inline bool IS_GROUP_GUID(uint64 guid);
// l - OBJECT_FIELD_GUID
// e - OBJECT_FIELD_ENTRY for GO (except GAMEOBJECT_TYPE_MO_TRANSPORT) and creatures or UNIT_FIELD_PETNUMBER for pets
// h - OBJECT_FIELD_GUID + 1
inline uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h);
//#define GUID_HIPART(x) (uint32)((uint64(x) >> 52)) & 0x0000FFFF)
inline uint32 GUID_HIPART(uint64 guid);
inline uint32 GUID_ENPART(uint64 x);
inline uint32 GUID_LOPART(uint64 x);
inline bool IsGuidHaveEnPart(uint64 guid);
inline char const* GetLogNameForGuid(uint64 guid);
uint64 MAKE_PAIR64(uint32 l, uint32 h)
{
return uint64(l | (uint64(h) << 32));
}
uint32 PAIR64_HIPART(uint64 x)
{
return (uint32)((x >> 32) & UI64LIT(0x00000000FFFFFFFF));
@@ -120,155 +68,4 @@ uint16 PAIR32_LOPART(uint32 x)
return (uint16)(x & 0x0000FFFF);
}
bool IS_EMPTY_GUID(uint64 guid)
{
return guid == 0;
}
bool IS_CREATURE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_UNIT;
}
bool IS_PET_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_PET;
}
bool IS_VEHICLE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_VEHICLE;
}
bool IS_CRE_OR_VEH_GUID(uint64 guid)
{
return IS_CREATURE_GUID(guid) || IS_VEHICLE_GUID(guid);
}
bool IS_CRE_OR_VEH_OR_PET_GUID(uint64 guid)
{
return IS_CRE_OR_VEH_GUID(guid) || IS_PET_GUID(guid);
}
bool IS_PLAYER_GUID(uint64 guid)
{
return guid != 0 && GUID_HIPART(guid) == HIGHGUID_PLAYER;
}
bool IS_UNIT_GUID(uint64 guid)
{
return IS_CRE_OR_VEH_OR_PET_GUID(guid) || IS_PLAYER_GUID(guid);
}
bool IS_ITEM_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_ITEM;
}
bool IS_GAMEOBJECT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_GAMEOBJECT;
}
bool IS_DYNAMICOBJECT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_DYNAMICOBJECT;
}
bool IS_CORPSE_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_CORPSE;
}
bool IS_TRANSPORT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_TRANSPORT;
}
bool IS_MO_TRANSPORT_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_MO_TRANSPORT;
}
bool IS_GROUP_GUID(uint64 guid)
{
return GUID_HIPART(guid) == HIGHGUID_GROUP;
}
uint64 MAKE_NEW_GUID(uint32 l, uint32 e, uint32 h)
{
return uint64(uint64(l) | (uint64(e) << 24) | (uint64(h) << 48));
}
uint32 GUID_HIPART(uint64 guid)
{
return (uint32)((uint64(guid) >> 48) & 0x0000FFFF);
}
uint32 GUID_ENPART(uint64 x)
{
return IsGuidHaveEnPart(x)
? (uint32)((x >> 24) & UI64LIT(0x0000000000FFFFFF))
: 0;
}
uint32 GUID_LOPART(uint64 x)
{
return IsGuidHaveEnPart(x)
? (uint32)(x & UI64LIT(0x0000000000FFFFFF))
: (uint32)(x & UI64LIT(0x00000000FFFFFFFF));
}
bool IsGuidHaveEnPart(uint64 guid)
{
switch (GUID_HIPART(guid))
{
case HIGHGUID_ITEM:
case HIGHGUID_PLAYER:
case HIGHGUID_DYNAMICOBJECT:
case HIGHGUID_CORPSE:
case HIGHGUID_GROUP:
return false;
case HIGHGUID_GAMEOBJECT:
case HIGHGUID_TRANSPORT:
case HIGHGUID_UNIT:
case HIGHGUID_PET:
case HIGHGUID_VEHICLE:
case HIGHGUID_MO_TRANSPORT:
default:
return true;
}
}
char const* GetLogNameForGuid(uint64 guid)
{
switch (GUID_HIPART(guid))
{
case HIGHGUID_ITEM:
return "item";
case HIGHGUID_PLAYER:
return guid ? "player" : "none";
case HIGHGUID_GAMEOBJECT:
return "gameobject";
case HIGHGUID_TRANSPORT:
return "transport";
case HIGHGUID_UNIT:
return "creature";
case HIGHGUID_PET:
return "pet";
case HIGHGUID_VEHICLE:
return "vehicle";
case HIGHGUID_DYNAMICOBJECT:
return "dynobject";
case HIGHGUID_CORPSE:
return "corpse";
case HIGHGUID_MO_TRANSPORT:
return "mo_transport";
case HIGHGUID_GROUP:
return "group";
default:
return "<unknown>";
}
}
#endif

View File

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
* Copyright (C) 2008-2021 TrinityCore <http://www.trinitycore.org/>
*/
#include "ObjectGuid.h"
#include "Log.h"
#include "World.h"
#include <sstream>
#include <iomanip>
ObjectGuid const ObjectGuid::Empty = ObjectGuid();
char const* ObjectGuid::GetTypeName(HighGuid high)
{
switch (high)
{
case HighGuid::Item: return "Item";
case HighGuid::Player: return "Player";
case HighGuid::GameObject: return "Gameobject";
case HighGuid::Transport: return "Transport";
case HighGuid::Unit: return "Creature";
case HighGuid::Pet: return "Pet";
case HighGuid::Vehicle: return "Vehicle";
case HighGuid::DynamicObject: return "DynObject";
case HighGuid::Corpse: return "Corpse";
case HighGuid::Mo_Transport: return "MoTransport";
case HighGuid::Instance: return "InstanceID";
case HighGuid::Group: return "Group";
default:
return "<unknown>";
}
}
std::string ObjectGuid::ToString() const
{
std::ostringstream str;
str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _guid << std::dec;
str << " Type: " << GetTypeName();
if (HasEntry())
str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry() << " ";
str << " Low: " << GetCounter();
return str.str();
}
ObjectGuid ObjectGuid::Global(HighGuid type, LowType counter)
{
return ObjectGuid(type, counter);
}
ObjectGuid ObjectGuid::MapSpecific(HighGuid type, uint32 entry, LowType counter)
{
return ObjectGuid(type, entry, counter);
}
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
{
buf << uint64(guid.GetRawValue());
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
{
guid.Set(buf.read<uint64>());
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
{
buf.append(guid._packedGuid);
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
{
buf.readPackGUID(reinterpret_cast<uint64&>(guid.Guid));
return buf;
}
void ObjectGuidGeneratorBase::HandleCounterOverflow(HighGuid high)
{
LOG_ERROR("server", "%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high));
World::StopNow(ERROR_EXIT_CODE);
}
#define GUID_TRAIT_INSTANTIATE_GUID( HIGH_GUID ) \
template class ObjectGuidGenerator< HIGH_GUID >;
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Container)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Player)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::GameObject)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Transport)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Unit)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Pet)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Vehicle)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::DynamicObject)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Mo_Transport)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Instance)
GUID_TRAIT_INSTANTIATE_GUID(HighGuid::Group)

View File

@@ -0,0 +1,323 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
* Copyright (C) 2008-2021 TrinityCore <http://www.trinitycore.org/>
*/
#ifndef ObjectGuid_h__
#define ObjectGuid_h__
#include "ByteBuffer.h"
#include "Define.h"
#include <deque>
#include <functional>
#include <list>
#include <memory>
#include <set>
#include <type_traits>
#include <vector>
#include <unordered_set>
enum TypeID
{
TYPEID_OBJECT = 0,
TYPEID_ITEM = 1,
TYPEID_CONTAINER = 2,
TYPEID_UNIT = 3,
TYPEID_PLAYER = 4,
TYPEID_GAMEOBJECT = 5,
TYPEID_DYNAMICOBJECT = 6,
TYPEID_CORPSE = 7
};
#define NUM_CLIENT_OBJECT_TYPES 8
enum TypeMask
{
TYPEMASK_OBJECT = 0x0001,
TYPEMASK_ITEM = 0x0002,
TYPEMASK_CONTAINER = 0x0006, // TYPEMASK_ITEM | 0x0004
TYPEMASK_UNIT = 0x0008, // creature
TYPEMASK_PLAYER = 0x0010,
TYPEMASK_GAMEOBJECT = 0x0020,
TYPEMASK_DYNAMICOBJECT = 0x0040,
TYPEMASK_CORPSE = 0x0080,
TYPEMASK_SEER = TYPEMASK_PLAYER | TYPEMASK_UNIT | TYPEMASK_DYNAMICOBJECT
};
enum class HighGuid
{
Item = 0x4000, // blizz 4000
Container = 0x4000, // blizz 4000
Player = 0x0000, // blizz 0000
GameObject = 0xF110, // blizz F110
Transport = 0xF120, // blizz F120 (for GAMEOBJECT_TYPE_TRANSPORT)
Unit = 0xF130, // blizz F130
Pet = 0xF140, // blizz F140
Vehicle = 0xF150, // blizz F550
DynamicObject = 0xF100, // blizz F100
Corpse = 0xF101, // blizz F100
Mo_Transport = 0x1FC0, // blizz 1FC0 (for GAMEOBJECT_TYPE_MO_TRANSPORT)
Instance = 0x1F40, // blizz 1F40
Group = 0x1F50,
};
template<HighGuid high>
struct ObjectGuidTraits
{
static bool const Global = false;
static bool const MapSpecific = false;
};
#define GUID_TRAIT_GLOBAL(highguid) \
template<> struct ObjectGuidTraits<highguid> \
{ \
static bool const Global = true; \
static bool const MapSpecific = false; \
};
#define GUID_TRAIT_MAP_SPECIFIC(highguid) \
template<> struct ObjectGuidTraits<highguid> \
{ \
static bool const Global = false; \
static bool const MapSpecific = true; \
};
GUID_TRAIT_GLOBAL(HighGuid::Player)
GUID_TRAIT_GLOBAL(HighGuid::Item)
GUID_TRAIT_GLOBAL(HighGuid::Mo_Transport)
GUID_TRAIT_GLOBAL(HighGuid::Group)
GUID_TRAIT_GLOBAL(HighGuid::Instance)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Transport)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Unit)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Vehicle)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Pet)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::GameObject)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::DynamicObject)
GUID_TRAIT_MAP_SPECIFIC(HighGuid::Corpse)
class ObjectGuid;
class PackedGuid;
struct PackedGuidReader
{
explicit PackedGuidReader(ObjectGuid& guid) : Guid(guid) { }
ObjectGuid& Guid;
};
class ObjectGuid
{
public:
static ObjectGuid const Empty;
typedef uint32 LowType;
template<HighGuid type>
static typename std::enable_if<ObjectGuidTraits<type>::Global, ObjectGuid>::type Create(LowType counter) { return Global(type, counter); }
template<HighGuid type>
static typename std::enable_if<ObjectGuidTraits<type>::MapSpecific, ObjectGuid>::type Create(uint32 entry, LowType counter) { return MapSpecific(type, entry, counter); }
ObjectGuid() : _guid(0) { }
explicit ObjectGuid(uint64 guid) : _guid(guid) { }
ObjectGuid(HighGuid hi, uint32 entry, LowType counter) : _guid(counter ? uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48) : 0) { }
ObjectGuid(HighGuid hi, LowType counter) : _guid(counter ? uint64(counter) | (uint64(hi) << 48) : 0) { }
PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
void Set(uint64 guid) { _guid = guid; }
void Clear() { _guid = 0; }
PackedGuid WriteAsPacked() const;
uint64 GetRawValue() const { return _guid; }
HighGuid GetHigh() const { return HighGuid((_guid >> 48) & 0x0000FFFF); }
uint32 GetEntry() const { return HasEntry() ? uint32((_guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0; }
LowType GetCounter() const
{
return HasEntry()
? LowType(_guid & UI64LIT(0x0000000000FFFFFF))
: LowType(_guid & UI64LIT(0x00000000FFFFFFFF));
}
static LowType GetMaxCounter(HighGuid high)
{
return HasEntry(high)
? LowType(0x00FFFFFF)
: LowType(0xFFFFFFFF);
}
ObjectGuid::LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
bool IsEmpty() const { return _guid == 0; }
bool IsCreature() const { return GetHigh() == HighGuid::Unit; }
bool IsPet() const { return GetHigh() == HighGuid::Pet; }
bool IsVehicle() const { return GetHigh() == HighGuid::Vehicle; }
bool IsCreatureOrPet() const { return IsCreature() || IsPet(); }
bool IsCreatureOrVehicle() const { return IsCreature() || IsVehicle(); }
bool IsAnyTypeCreature() const { return IsCreature() || IsPet() || IsVehicle(); }
bool IsPlayer() const { return !IsEmpty() && GetHigh() == HighGuid::Player; }
bool IsUnit() const { return IsAnyTypeCreature() || IsPlayer(); }
bool IsItem() const { return GetHigh() == HighGuid::Item; }
bool IsGameObject() const { return GetHigh() == HighGuid::GameObject; }
bool IsDynamicObject() const { return GetHigh() == HighGuid::DynamicObject; }
bool IsCorpse() const { return GetHigh() == HighGuid::Corpse; }
bool IsTransport() const { return GetHigh() == HighGuid::Transport; }
bool IsMOTransport() const { return GetHigh() == HighGuid::Mo_Transport; }
bool IsAnyTypeGameObject() const { return IsGameObject() || IsTransport() || IsMOTransport(); }
bool IsInstance() const { return GetHigh() == HighGuid::Instance; }
bool IsGroup() const { return GetHigh() == HighGuid::Group; }
static TypeID GetTypeId(HighGuid high)
{
switch (high)
{
case HighGuid::Item: return TYPEID_ITEM;
//case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently
case HighGuid::Unit: return TYPEID_UNIT;
case HighGuid::Pet: return TYPEID_UNIT;
case HighGuid::Player: return TYPEID_PLAYER;
case HighGuid::GameObject: return TYPEID_GAMEOBJECT;
case HighGuid::DynamicObject: return TYPEID_DYNAMICOBJECT;
case HighGuid::Corpse: return TYPEID_CORPSE;
case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT;
case HighGuid::Vehicle: return TYPEID_UNIT;
// unknown
case HighGuid::Instance:
case HighGuid::Group:
default: return TYPEID_OBJECT;
}
}
TypeID GetTypeId() const { return GetTypeId(GetHigh()); }
operator bool() const { return !IsEmpty(); }
bool operator!() const { return !(bool(*this)); }
bool operator==(ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); }
bool operator!=(ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); }
bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
bool operator<= (ObjectGuid const& guid) const { return GetRawValue() <= guid.GetRawValue(); }
static char const* GetTypeName(HighGuid high);
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
std::string ToString() const;
private:
static bool HasEntry(HighGuid high)
{
switch (high)
{
case HighGuid::Item:
case HighGuid::Player:
case HighGuid::DynamicObject:
case HighGuid::Corpse:
case HighGuid::Mo_Transport:
case HighGuid::Instance:
case HighGuid::Group:
return false;
case HighGuid::GameObject:
case HighGuid::Transport:
case HighGuid::Unit:
case HighGuid::Pet:
case HighGuid::Vehicle:
default:
return true;
}
}
bool HasEntry() const { return HasEntry(GetHigh()); }
static ObjectGuid Global(HighGuid type, LowType counter);
static ObjectGuid MapSpecific(HighGuid type, uint32 entry, LowType counter);
explicit ObjectGuid(uint32 const&) = delete; // no implementation, used to catch wrong type assignment
ObjectGuid(HighGuid, uint32, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
ObjectGuid(HighGuid, uint64 counter) = delete; // no implementation, used to catch wrong type assignment
// used to catch wrong type assignment
operator int64() const = delete;
uint64 _guid;
};
// Some Shared defines
typedef std::set<ObjectGuid> GuidSet;
typedef std::list<ObjectGuid> GuidList;
typedef std::deque<ObjectGuid> GuidDeque;
typedef std::vector<ObjectGuid> GuidVector;
typedef std::unordered_set<ObjectGuid> GuidUnorderedSet;
// minimum buffer size for packed guid is 9 bytes
#define PACKED_GUID_MIN_BUFFER_SIZE 9
class PackedGuid
{
friend ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
public:
explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(0); }
explicit PackedGuid(uint64 guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid); }
explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
std::size_t size() const { return _packedGuid.size(); }
private:
ByteBuffer _packedGuid;
};
class ObjectGuidGeneratorBase
{
public:
ObjectGuidGeneratorBase(ObjectGuid::LowType start = 1) : _nextGuid(start) { }
virtual void Set(ObjectGuid::LowType val) { _nextGuid = val; }
virtual ObjectGuid::LowType Generate() = 0;
ObjectGuid::LowType GetNextAfterMaxUsed() const { return _nextGuid; }
virtual ~ObjectGuidGeneratorBase() { }
protected:
static void HandleCounterOverflow(HighGuid high);
ObjectGuid::LowType _nextGuid;
};
template<HighGuid high>
class ObjectGuidGenerator : public ObjectGuidGeneratorBase
{
public:
explicit ObjectGuidGenerator(ObjectGuid::LowType start = 1) : ObjectGuidGeneratorBase(start) { }
ObjectGuid::LowType Generate() override
{
if (_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1)
HandleCounterOverflow(high);
return _nextGuid++;
}
};
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid);
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid);
inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this); }
namespace std
{
template<>
struct hash<ObjectGuid>
{
public:
size_t operator()(ObjectGuid const& key) const
{
return std::hash<uint64>()(key.GetRawValue());
}
};
}
#endif // ObjectGuid_h__

View File

@@ -18,7 +18,7 @@ UpdateData::UpdateData() : m_blockCount(0)
m_outOfRangeGUIDs.reserve(15);
}
void UpdateData::AddOutOfRangeGUID(uint64 guid)
void UpdateData::AddOutOfRangeGUID(ObjectGuid guid)
{
m_outOfRangeGUIDs.push_back(guid);
}
@@ -104,9 +104,9 @@ bool UpdateData::BuildPacket(WorldPacket* packet)
buf << (uint8) UPDATETYPE_OUT_OF_RANGE_OBJECTS;
buf << (uint32) m_outOfRangeGUIDs.size();
for (std::vector<uint64>::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i)
for (ObjectGuid const guid : m_outOfRangeGUIDs)
{
buf.appendPackGUID(*i);
buf << guid.WriteAsPacked();
}
}

View File

@@ -8,6 +8,7 @@
#define __UPDATEDATA_H
#include "ByteBuffer.h"
#include "ObjectGuid.h"
class WorldPacket;
@@ -41,7 +42,7 @@ class UpdateData
public:
UpdateData();
void AddOutOfRangeGUID(uint64 guid);
void AddOutOfRangeGUID(ObjectGuid guid);
void AddUpdateBlock(const ByteBuffer& block);
void AddUpdateBlock(const UpdateData& block);
bool BuildPacket(WorldPacket* packet);
@@ -50,7 +51,7 @@ public:
protected:
uint32 m_blockCount;
std::vector<uint64> m_outOfRangeGUIDs;
GuidVector m_outOfRangeGUIDs;
ByteBuffer m_data;
void Compress(void* dst, uint32* dst_size, void* src, int src_size);

View File

@@ -24,7 +24,7 @@
#include "WorldPacket.h"
#include "WorldSession.h"
Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : 0, true),
Pet::Pet(Player* owner, PetType type) : Guardian(nullptr, owner ? owner->GetGUID() : ObjectGuid::Empty, true),
m_usedTalentCount(0), m_removed(false), m_owner(owner),
m_happinessTimer(PET_LOSE_HAPPINES_INTERVAL), m_petType(type), m_duration(0),
m_auraRaidUpdateMask(0), m_loading(false), m_petRegenTimer(PET_FOCUS_REGEN_INTERVAL), m_declinedname(nullptr), m_tempspellTarget(nullptr), m_tempoldTarget(nullptr), m_tempspellIsPositive(false), m_tempspell(0), asynchLoadType(PET_LOAD_DEFAULT)
@@ -53,14 +53,14 @@ void Pet::AddToWorld()
if (!IsInWorld())
{
///- Register the pet for guid lookup
sObjectAccessor->AddObject(this);
GetMap()->GetObjectsStore().Insert<Pet>(GetGUID(), this);
Unit::AddToWorld();
Motion_Initialize();
AIM_Initialize();
}
// pussywizard: apply ICC buff to pets
if (IS_PLAYER_GUID(GetOwnerGUID()) && GetMapId() == 631 && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/))
if (GetOwnerGUID().IsPlayer() && GetMapId() == 631 && FindMap() && FindMap()->ToInstanceMap() && FindMap()->ToInstanceMap()->GetInstanceScript() && FindMap()->ToInstanceMap()->GetInstanceScript()->GetData(251 /*DATA_BUFF_AVAILABLE*/))
if (Unit* owner = GetOwner())
if (Player* plr = owner->ToPlayer())
{
@@ -91,14 +91,14 @@ void Pet::RemoveFromWorld()
{
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
sObjectAccessor->RemoveObject(this);
GetMap()->GetObjectsStore().Remove<Pet>(GetGUID());
}
}
SpellCastResult Pet::TryLoadFromDB(Player* owner, bool current /*= false*/, PetType mandatoryPetType /*= MAX_PET_TYPE*/)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt8(1, uint8(current ? PET_SAVE_AS_CURRENT : PET_SAVE_NOT_IN_SLOT));
PreparedQueryResult result = CharacterDatabase.AsyncQuery(stmt);
@@ -157,28 +157,28 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui
if (owner->getClass() == CLASS_DEATH_KNIGHT && !owner->CanSeeDKPet()) // DK Pet exception
return false;
uint32 ownerid = owner->GetGUIDLow();
ObjectGuid::LowType ownerGuid = owner->GetGUID().GetCounter();
PreparedStatement* stmt;
if (petnumber)
{
// Known petnumber entry
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY);
stmt->setUInt32(0, ownerid);
stmt->setUInt32(0, ownerGuid);
stmt->setUInt32(1, petnumber);
}
else if (current)
{
// Current pet (slot 0)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT);
stmt->setUInt32(0, ownerid);
stmt->setUInt32(0, ownerGuid);
stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
}
else if (petentry)
{
// known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_ENTRY_AND_SLOT_2);
stmt->setUInt32(0, ownerid);
stmt->setUInt32(0, ownerGuid);
stmt->setUInt32(1, petentry);
stmt->setUInt8(2, uint8(PET_SAVE_AS_CURRENT));
stmt->setUInt8(3, uint8(PET_SAVE_LAST_STABLE_SLOT));
@@ -187,13 +187,14 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui
{
// Any current or other non-stabled pet (for hunter "call pet")
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_BY_SLOT);
stmt->setUInt32(0, ownerid);
stmt->setUInt32(0, ownerGuid);
stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
}
if (AsynchPetSummon* info = owner->GetSession()->_loadPetFromDBFirstCallback.GetSecondParam())
delete info;
owner->GetSession()->_loadPetFromDBFirstCallback.Reset();
owner->GetSession()->_loadPetFromDBFirstCallback.SetFirstParam(asynchLoadType);
owner->GetSession()->_loadPetFromDBFirstCallback.SetSecondParam(info);
@@ -204,7 +205,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry, ui
void Pet::SavePetToDB(PetSaveMode mode, bool logout)
{
// not save not player pets
if (!IS_PLAYER_GUID(GetOwnerGUID()))
if (!GetOwnerGUID().IsPlayer())
return;
// dont allow to save pet when it is loaded, possibly bugs action bar!, save only fully controlled creature
@@ -242,7 +243,7 @@ void Pet::SavePetToDB(PetSaveMode mode, bool logout)
// current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT)
{
uint32 ownerLowGUID = GUID_LOPART(GetOwnerGUID());
ObjectGuid::LowType ownerLowGUID = GetOwnerGUID().GetCounter();
trans = CharacterDatabase.BeginTransaction();
// remove current data
@@ -306,7 +307,7 @@ void Pet::SavePetToDB(PetSaveMode mode, bool logout)
}
}
void Pet::DeleteFromDB(uint32 guidlow)
void Pet::DeleteFromDB(ObjectGuid::LowType guidlow)
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
@@ -644,8 +645,8 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
if (!IsPositionValid())
{
LOG_ERROR("server", "Pet (guidlow %d, entry %d) not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUIDLow(), GetEntry(), GetPositionX(), GetPositionY());
LOG_ERROR("server", "Pet %s not created base at creature. Suggested coordinates isn't valid (X: %f Y: %f)",
GetGUID().ToString().c_str(), GetPositionX(), GetPositionY());
return false;
}
@@ -684,7 +685,7 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.pet", "Pet::CreateBaseForTamed");
#endif
uint32 guid = sObjectMgr->GenerateLowGuid(HIGHGUID_PET);
ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Pet>();
uint32 pet_number = sObjectMgr->GeneratePetNumber();
if (!Create(guid, map, phaseMask, cinfo->Entry, pet_number))
return false;
@@ -1260,7 +1261,7 @@ void Pet::_SaveSpells(SQLTransaction& trans)
void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("entities.pet", "Loading auras for pet %u", GetGUIDLow());
LOG_DEBUG("entities.pet", "Loading auras for pet %s", GetGUID().ToString().c_str());
#endif
if (result)
@@ -1270,7 +1271,7 @@ void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff)
int32 damage[3];
int32 baseDamage[3];
Field* fields = result->Fetch();
uint64 caster_guid = fields[0].GetUInt64();
ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64());
// nullptr guid stored - pet is the caster of the spell - see Pet::_SaveAuras
if (!caster_guid)
caster_guid = GetGUID();
@@ -1397,13 +1398,13 @@ void Pet::_SaveAuras(SQLTransaction& trans, bool logout)
}
// don't save guid of caster in case we are caster of the spell - guid for pet is generated every pet load, so it won't match saved guid anyways
uint64 casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? 0 : itr->second->GetCasterGUID();
ObjectGuid casterGUID = (itr->second->GetCasterGUID() == GetGUID()) ? ObjectGuid::Empty : itr->second->GetCasterGUID();
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA);
stmt->setUInt32(index++, m_charmInfo->GetPetNumber());
stmt->setUInt64(index++, casterGUID);
stmt->setUInt64(index++, casterGUID.GetRawValue());
stmt->setUInt32(index++, itr->second->GetId());
stmt->setUInt8(index++, effMask);
stmt->setUInt8(index++, recalculateMask);
@@ -1802,7 +1803,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= nullptr*/)
// xinef: zomg! sync query
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt32(1, except_petnumber);
PreparedQueryResult resultPets = CharacterDatabase.Query(stmt);
@@ -1812,7 +1813,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= nullptr*/)
// xinef: zomg! sync query
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_LIST);
stmt->setUInt32(0, owner->GetGUIDLow());
stmt->setUInt32(0, owner->GetGUID().GetCounter());
stmt->setUInt32(1, except_petnumber);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -1968,15 +1969,16 @@ bool Pet::IsPermanentPetFor(Player* owner) const
}
}
bool Pet::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number)
{
ASSERT(map);
SetMap(map);
SetPhaseMask(phaseMask, false);
Object::_Create(guidlow, pet_number, HIGHGUID_PET);
m_DBTableGuid = guidlow;
Object::_Create(guidlow, pet_number, HighGuid::Pet);
m_spawnId = guidlow;
m_originalEntry = Entry;
if (!InitEntry(Entry))
@@ -2184,7 +2186,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as
Map* map = player->GetMap();
uint32 pet_number = sObjectMgr->GeneratePetNumber();
if (!pet->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_PET), map, player->GetPhaseMask(), info->m_entry, pet_number))
if (!pet->Create(map->GenerateLowGuid<HighGuid::Pet>(), map, player->GetPhaseMask(), info->m_entry, pet_number))
{
LOG_ERROR("server", "no such creature entry %u", info->m_entry);
delete pet;
@@ -2247,7 +2249,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as
// we are almost at home...
if (asynchLoadType == PET_LOAD_SUMMON_PET)
{
Unit* caster = ObjectAccessor::GetObjectInMap(info->m_casterGUID, map, (Unit*)nullptr);
Unit* caster = ObjectAccessor::GetUnit(*player, info->m_casterGUID);
if (!caster)
caster = player;
@@ -2282,7 +2284,7 @@ void Pet::HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 as
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
pet->setDeathState(ALIVE);
pet->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_POSSESSED))); // xinef: just in case
pet->SetHealth(pet->CountPctFromMaxHealth(uint32(info->m_casterGUID))); // damage for this effect is saved in caster guid, dont create next variable...
pet->SetHealth(pet->CountPctFromMaxHealth(uint32(info->m_casterGUID.GetRawValue()))); // damage for this effect is saved in caster guid, dont create next variable...
//AIM_Initialize();
//owner->PetSpellInitialize();
@@ -2338,7 +2340,7 @@ void Pet::RemoveSpellCooldown(uint32 spell_id, bool update /* = false */)
{
WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8);
data << uint32(spell_id);
data << uint64(GetGUID());
data << GetGUID();
playerOwner->SendDirectMessage(&data);
}
}

View File

@@ -24,7 +24,7 @@ struct PetSpell
class AsynchPetSummon
{
public:
AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID) :
AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, ObjectGuid casterGUID) :
m_entry(entry), pos(position), m_petType(petType),
m_duration(duration), m_createdBySpell(createdBySpell), m_casterGUID(casterGUID) { }
@@ -32,7 +32,7 @@ public:
Position pos;
PetType m_petType;
uint32 m_duration, m_createdBySpell;
uint64 m_casterGUID;
ObjectGuid m_casterGUID;
};
typedef std::unordered_map<uint32, PetSpell> PetSpellMap;
@@ -58,7 +58,7 @@ public:
bool IsPermanentPetFor(Player* owner) const; // pet have tab in character windows and set UNIT_FIELD_PETNUMBER
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
bool Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 pet_number);
bool CreateBaseAtCreature(Creature* creature);
bool CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
@@ -67,7 +67,7 @@ public:
bool isBeingLoaded() const override { return m_loading;}
void SavePetToDB(PetSaveMode mode, bool logout);
void Remove(PetSaveMode mode, bool returnreagent = false);
static void DeleteFromDB(uint32 guidlow);
static void DeleteFromDB(ObjectGuid::LowType guidlow);
void setDeathState(DeathState s, bool despawn = false) override; // overwrite virtual Creature::setDeathState and Unit::setDeathState
void Update(uint32 diff) override; // overwrite virtual Creature::Update and Unit::Update

File diff suppressed because it is too large Load Diff

View File

@@ -156,7 +156,7 @@ typedef std::unordered_map<uint32, PlayerTalent*> PlayerTalentMap;
typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap;
typedef std::list<SpellModifier*> SpellModList;
typedef std::list<uint64> WhisperListContainer;
typedef GuidList WhisperListContainer;
struct SpellCooldown
{
@@ -503,7 +503,8 @@ enum AtLoginFlags
AT_LOGIN_CHANGE_RACE = 0x80,
AT_LOGIN_RESET_AP = 0x100,
AT_LOGIN_RESET_ARENA = 0x200,
AT_LOGIN_CHECK_ACHIEVS = 0x400
AT_LOGIN_CHECK_ACHIEVS = 0x400,
AT_LOGIN_RESURRECT = 0x800
};
typedef std::map<uint32, QuestStatusData> QuestStatusMap;
@@ -642,17 +643,13 @@ enum EquipmentSetUpdateState
struct EquipmentSet
{
EquipmentSet()
{
for (unsigned int & Item : Items)
Item = 0;
}
EquipmentSet() { }
uint64 Guid{0};
uint64 Guid;
std::string Name;
std::string IconName;
uint32 IgnoreMask{0};
uint32 Items[EQUIPMENT_SLOT_END];
ObjectGuid Items[EQUIPMENT_SLOT_END];
EquipmentSetUpdateState state{EQUIPMENT_SET_NEW};
};
@@ -791,7 +788,8 @@ enum PlayerLoginQueryIndex
PLAYER_LOGIN_QUERY_LOAD_SEASONAL_QUEST_STATUS = 31,
PLAYER_LOGIN_QUERY_LOAD_MONTHLY_QUEST_STATUS = 32,
PLAYER_LOGIN_QUERY_LOAD_BREW_OF_THE_MONTH = 34,
MAX_PLAYER_LOGIN_QUERY,
PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION = 35,
MAX_PLAYER_LOGIN_QUERY
};
enum PlayerDelayedOperations
@@ -983,7 +981,7 @@ struct BGData
bool isInvited{false};
bool bgIsRandom{false};
std::set<uint32> bgAfkReporter;
GuidSet bgAfkReporter;
uint8 bgAfkReportedCount{0};
time_t bgAfkReportedTimer{0};
};
@@ -1007,23 +1005,23 @@ struct EntryPointData
class TradeData
{
public: // constructors
TradeData(Player* player, Player* trader) :
m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false),
m_money(0), m_spell(0), m_spellCastItem(0) { memset(m_items, 0, TRADE_SLOT_COUNT * sizeof(uint64)); }
TradeData(Player* player, Player* trader) : m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false), m_money(0), m_spell(0)
{
}
[[nodiscard]] Player* GetTrader() const { return m_trader; }
[[nodiscard]] TradeData* GetTraderData() const;
[[nodiscard]] Item* GetItem(TradeSlots slot) const;
[[nodiscard]] bool HasItem(uint64 itemGuid) const;
[[nodiscard]] TradeSlots GetTradeSlotForItem(uint64 itemGuid) const;
[[nodiscard]] bool HasItem(ObjectGuid itemGuid) const;
[[nodiscard]] TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const;
void SetItem(TradeSlots slot, Item* item);
[[nodiscard]] uint32 GetSpell() const { return m_spell; }
void SetSpell(uint32 spell_id, Item* castItem = nullptr);
[[nodiscard]] Item* GetSpellCastItem() const;
[[nodiscard]] bool HasSpellCastItem() const { return m_spellCastItem != 0; }
[[nodiscard]] bool HasSpellCastItem() const { return m_spellCastItem; }
[[nodiscard]] uint32 GetMoney() const { return m_money; }
void SetMoney(uint32 money);
@@ -1047,9 +1045,9 @@ private: // fields
uint32 m_money; // m_player place money to trade
uint32 m_spell; // m_player apply spell to non-traded slot item
uint64 m_spellCastItem; // applied spell casted by item use
ObjectGuid m_spellCastItem; // applied spell casted by item use
uint64 m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot
ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded itmes from m_player side including non-traded slot
};
class KillRewarder
@@ -1128,10 +1126,10 @@ public:
}
[[nodiscard]] bool IsSummonAsSpectator() const { return m_summon_asSpectator && m_summon_expire >= time(nullptr); }
void SetSummonAsSpectator(bool on) { m_summon_asSpectator = on; }
void SummonIfPossible(bool agree, uint32 summoner_guid);
void SummonIfPossible(bool agree, ObjectGuid summoner_guid);
[[nodiscard]] time_t GetSummonExpireTimer() const { return m_summon_expire; }
bool Create(uint32 guidlow, CharacterCreateInfo* createInfo);
bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo);
void Update(uint32 time) override;
@@ -1150,8 +1148,8 @@ public:
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool onEnterMap);
bool CanInteractWithQuestGiver(Object* questGiver);
Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask);
[[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const;
Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask);
[[nodiscard]] GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const;
void ToggleAFK();
void ToggleDND();
@@ -1220,14 +1218,14 @@ public:
[[nodiscard]] Pet* GetPet() const;
bool IsPetDismissed();
void SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime, uint32 createdBySpell, uint64 casterGUID, uint8 asynchLoadType);
void SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime, uint32 createdBySpell, ObjectGuid casterGUID, uint8 asynchLoadType);
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
[[nodiscard]] uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
void Say(std::string const& text, const uint32 language);
void Yell(std::string const& text, const uint32 language);
void TextEmote(std::string const& text);
void Whisper(std::string const& text, const uint32 language, uint64 receiver);
void Whisper(std::string const& text, const uint32 language, ObjectGuid receiver);
/*********************************************************/
/*** STORAGE SYSTEM ***/
@@ -1238,7 +1236,7 @@ public:
uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const;
uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const;
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
[[nodiscard]] Item* GetItemByGuid(uint64 guid) const;
[[nodiscard]] Item* GetItemByGuid(ObjectGuid guid) const;
[[nodiscard]] Item* GetItemByEntry(uint32 entry) const;
[[nodiscard]] Item* GetItemByPos(uint16 pos) const;
[[nodiscard]] Item* GetItemByPos(uint8 bag, uint8 slot) const;
@@ -1314,8 +1312,8 @@ public:
InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr) const;
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const;
void AddRefundReference(uint32 it);
void DeleteRefundReference(uint32 it);
void AddRefundReference(ObjectGuid itemGUID);
void DeleteRefundReference(ObjectGuid itemGUID);
void ApplyEquipCooldown(Item* pItem);
void SetAmmo(uint32 item);
@@ -1349,7 +1347,7 @@ public:
[[nodiscard]] uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END - KEYRING_SLOT_START; }
void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = nullptr, uint32 itemid = 0);
void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param);
void SendSellError(SellResult msg, Creature* creature, uint64 guid, uint32 param);
void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param);
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
[[nodiscard]] uint32 GetWeaponProficiency() const { return m_WeaponProficiency; }
@@ -1361,7 +1359,7 @@ public:
return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip();
}
void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false, bool sendChatMessage = true);
bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore);
float GetReputationPriceDiscount(Creature const* creature) const;
@@ -1388,7 +1386,7 @@ public:
void AddItemDurations(Item* item);
void RemoveItemDurations(Item* item);
void SendItemDurations();
void LoadCorpse();
void LoadCorpse(PreparedQueryResult result);
void LoadPet();
bool AddItem(uint32 itemId, uint32 count);
@@ -1415,10 +1413,10 @@ public:
int32 GetQuestLevel(Quest const* quest) const { return quest && (quest->GetQuestLevel() > 0) ? quest->GetQuestLevel() : getLevel(); }
void PrepareQuestMenu(uint64 guid);
void SendPreparedQuest(uint64 guid);
void PrepareQuestMenu(ObjectGuid guid);
void SendPreparedQuest(ObjectGuid guid);
[[nodiscard]] bool IsActiveQuest(uint32 quest_id) const;
Quest const* GetNextQuest(uint64 guid, Quest const* quest);
Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest);
bool CanSeeStartQuest(Quest const* quest);
bool CanTakeQuest(Quest const* quest, bool msg);
bool CanAddQuest(Quest const* quest, bool msg);
@@ -1509,11 +1507,11 @@ public:
void GroupEventHappens(uint32 questId, WorldObject const* pEventObject);
void ItemAddedQuestCheck(uint32 entry, uint32 count);
void ItemRemovedQuestCheck(uint32 entry, uint32 count);
void KilledMonster(CreatureTemplate const* cInfo, uint64 guid);
void KilledMonsterCredit(uint32 entry, uint64 guid);
void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid);
void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty);
void KilledPlayerCredit();
void KillCreditGO(uint32 entry, uint64 guid = 0);
void TalkedToCreature(uint32 entry, uint64 guid);
void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty);
void TalkedToCreature(uint32 entry, ObjectGuid guid);
void MoneyChanged(uint32 value);
void ReputationChanged(FactionEntry const* factionEntry);
void ReputationChanged2(FactionEntry const* factionEntry);
@@ -1530,11 +1528,11 @@ public:
void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver);
void SendPushToPartyResponse(Player const* player, uint8 msg) const;
void SendQuestUpdateAddItem(Quest const* quest, uint32 item_idx, uint16 count);
void SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count);
void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count);
void SendQuestUpdateAddPlayer(Quest const* quest, uint16 old_count, uint16 add_count);
uint64 GetDivider() { return m_divider; }
void SetDivider(uint64 guid) { m_divider = guid; }
ObjectGuid GetDivider() { return m_divider; }
void SetDivider(ObjectGuid guid = ObjectGuid::Empty) { m_divider = guid; }
uint32 GetInGameTime() { return m_ingametime; }
@@ -1549,15 +1547,15 @@ public:
/*** LOAD SYSTEM ***/
/*********************************************************/
bool LoadFromDB(uint32 guid, SQLQueryHolder* holder);
bool LoadFromDB(ObjectGuid guid, SQLQueryHolder* holder);
[[nodiscard]] bool isBeingLoaded() const override;
void Initialize(uint32 guid);
void Initialize(ObjectGuid::LowType guid);
static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index);
static float GetFloatValueFromArray(Tokenizer const& data, uint16 index);
static uint32 GetZoneIdFromDB(uint64 guid);
static uint32 GetLevelFromStorage(uint64 guid);
static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid);
static uint32 GetZoneIdFromDB(ObjectGuid guid);
static uint32 GetLevelFromStorage(ObjectGuid::LowType guid);
static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid::LowType guid);
static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; }
@@ -1571,17 +1569,17 @@ public:
static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value);
static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value);
static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid);
static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair);
static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid);
static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally);
static void DeleteFromDB(ObjectGuid::LowType lowGuid, uint32 accountId, bool updateRealmChars, bool deleteFinally);
static void DeleteOldCharacters();
static void DeleteOldCharacters(uint32 keepDays);
bool m_mailsUpdated;
void SetBindPoint(uint64 guid);
void SendTalentWipeConfirm(uint64 guid);
void SetBindPoint(ObjectGuid guid);
void SendTalentWipeConfirm(ObjectGuid guid);
void ResetPetTalents();
void CalcRage(uint32 damage, bool attacker);
void RegenerateAll();
@@ -1620,17 +1618,17 @@ public:
[[nodiscard]] Unit* GetSelectedUnit() const;
[[nodiscard]] Player* GetSelectedPlayer() const;
void SetTarget(uint64 /*guid*/) override { } /// Used for serverside target changes, does not apply to players
void SetSelection(uint64 guid);
void SetTarget(ObjectGuid /*guid*/ = ObjectGuid::Empty) override { } /// Used for serverside target changes, does not apply to players
void SetSelection(ObjectGuid guid);
[[nodiscard]] uint8 GetComboPoints() const { return m_comboPoints; }
[[nodiscard]] uint64 GetComboTarget() const { return m_comboTarget; }
[[nodiscard]] ObjectGuid GetComboTarget() const { return m_comboTarget; }
void AddComboPoints(Unit* target, int8 count);
void ClearComboPoints();
void SendComboPoints();
void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, uint32 item_guid = 0, uint32 item_count = 0);
void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0);
void SendNewMail();
void UpdateNextMailTimeAndUnreads();
void AddNewMailDeliverTime(time_t deliver_time);
@@ -1653,13 +1651,13 @@ public:
uint32 totalMailCount;
time_t m_nextMailDelivereTime;
typedef std::unordered_map<uint32, Item*> ItemMap;
typedef std::unordered_map<ObjectGuid::LowType, Item*> ItemMap;
ItemMap mMitems; //template defined in objectmgr.cpp
Item* GetMItem(uint32 id)
Item* GetMItem(ObjectGuid::LowType itemLowGuid)
{
ItemMap::const_iterator itr = mMitems.find(id);
ItemMap::const_iterator itr = mMitems.find(itemLowGuid);
return itr != mMitems.end() ? itr->second : nullptr;
}
@@ -1667,12 +1665,12 @@ public:
{
ASSERT(it);
//ASSERT deleted, because items can be added before loading
mMitems[it->GetGUIDLow()] = it;
mMitems[it->GetGUID().GetCounter()] = it;
}
bool RemoveMItem(uint32 id)
bool RemoveMItem(ObjectGuid::LowType itemLowGuid)
{
return !!mMitems.erase(id);
return !!mMitems.erase(itemLowGuid);
}
void PetSpellInitialize();
@@ -1710,7 +1708,7 @@ public:
void BuildPetTalentsInfoData(WorldPacket* data);
void SendTalentsInfoData(bool pet);
void LearnTalent(uint32 talentId, uint32 talentRank);
void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank);
void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank);
bool addTalent(uint32 spellId, uint8 addSpecMask, uint8 oldTalentRank);
void _removeTalent(PlayerTalentMap::iterator& itr, uint8 specMask);
@@ -1806,7 +1804,7 @@ public:
void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; }
void UpdatePotionCooldown();
void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana)
{
m_resurrectGUID = guid;
m_resurrectMap = mapId;
@@ -1816,9 +1814,9 @@ public:
m_resurrectHealth = health;
m_resurrectMana = mana;
}
void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); }
[[nodiscard]] bool isResurrectRequestedBy(uint64 guid) const { return m_resurrectGUID && m_resurrectGUID == guid; }
[[nodiscard]] bool isResurrectRequested() const { return m_resurrectGUID != 0; }
void clearResurrectRequestData() { setResurrectRequestData(ObjectGuid::Empty, 0, 0.0f, 0.0f, 0.0f, 0, 0); }
[[nodiscard]] bool isResurrectRequestedBy(ObjectGuid guid) const { return m_resurrectGUID && m_resurrectGUID == guid; }
[[nodiscard]] bool isResurrectRequested() const { return m_resurrectGUID; }
void ResurectUsingRequestData();
[[nodiscard]] uint8 getCinematic() const
@@ -1881,7 +1879,7 @@ public:
bool IsInSameGroupWith(Player const* p) const;
bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != nullptr && GetGroup() == p->GetGroup()); }
void UninviteFromGroup();
static void RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = nullptr);
static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr);
void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); }
void SendUpdateToOutOfRangeGroupMembers();
@@ -1889,18 +1887,18 @@ public:
{
SetUInt32Value(PLAYER_GUILDID, GuildId);
// xinef: update global storage
sWorld->UpdateGlobalPlayerGuild(GetGUIDLow(), GuildId);
sWorld->UpdateGlobalPlayerGuild(GetGUID().GetCounter(), GuildId);
}
void SetRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); }
[[nodiscard]] uint8 GetRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); }
void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
[[nodiscard]] uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); }
[[nodiscard]] Guild* GetGuild() const;
static uint32 GetGuildIdFromStorage(uint32 guid);
static uint32 GetGroupIdFromStorage(uint32 guid);
static uint32 GetArenaTeamIdFromStorage(uint32 guid, uint8 slot);
static uint32 GetGuildIdFromStorage(ObjectGuid::LowType guid);
static uint32 GetGroupIdFromStorage(ObjectGuid::LowType guid);
static uint32 GetArenaTeamIdFromStorage(ObjectGuid::LowType guid, uint8 slot);
uint32 GetGuildIdInvited() { return m_GuildIdInvited; }
static void RemovePetitionsAndSigns(uint64 guid, uint32 type);
static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type);
// Arena Team
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
@@ -1910,8 +1908,8 @@ public:
}
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value);
uint32 GetArenaPersonalRating(uint8 slot) const;
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);
static void LeaveAllArenaTeams(uint64 guid);
static uint32 GetArenaTeamIdFromDB(ObjectGuid guid, uint8 slot);
static void LeaveAllArenaTeams(ObjectGuid guid);
[[nodiscard]] uint32 GetArenaTeamId(uint8 slot) const;
void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; }
uint32 GetArenaTeamIdInvited() { return m_ArenaTeamIdInvited; }
@@ -1989,8 +1987,8 @@ public:
void UpdateManaRegen();
void UpdateRuneRegen(RuneType rune);
[[nodiscard]] uint64 GetLootGUID() const { return m_lootGuid; }
void SetLootGUID(uint64 guid) { m_lootGuid = guid; }
[[nodiscard]] ObjectGuid GetLootGUID() const { return m_lootGuid; }
void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; }
void RemovedInsignia(Player* looterPlr);
@@ -2012,7 +2010,7 @@ public:
void SendDungeonDifficulty(bool IsInGroup);
void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1);
static void ResetInstances(uint64 guid, uint8 method, bool isRaid);
static void ResetInstances(ObjectGuid guid, uint8 method, bool isRaid);
void SendResetInstanceSuccess(uint32 MapId);
void SendResetInstanceFailed(uint32 reason, uint32 MapId);
void SendResetFailedNotify(uint32 mapid);
@@ -2029,9 +2027,12 @@ public:
void SendTeleportAckPacket();
[[nodiscard]] Corpse* GetCorpse() const;
void SpawnCorpseBones();
void CreateCorpse();
void SpawnCorpseBones(bool triggerSave = true);
Corpse* CreateCorpse();
void KillPlayer();
static void OfflineResurrect(ObjectGuid const guid, SQLTransaction& trans);
bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; }
WorldLocation GetCorpseLocation() const { return _corpseLocation; }
uint32 GetResurrectionSpellId();
void ResurrectPlayer(float restore_percent, bool applySickness = false);
void BuildPlayerRepop();
@@ -2228,9 +2229,9 @@ public:
PlayerMenu* PlayerTalkClass;
std::vector<ItemSetEffect*> ItemSetEff;
void SendLoot(uint64 guid, LootType loot_type);
void SendLootError(uint64 guid, LootError error);
void SendLootRelease(uint64 guid);
void SendLoot(ObjectGuid guid, LootType loot_type);
void SendLootError(ObjectGuid guid, LootError error);
void SendLootRelease(ObjectGuid guid);
void SendNotifyLootItemRemoved(uint8 lootSlot);
void SendNotifyLootMoneyRemoved();
@@ -2394,12 +2395,11 @@ public:
void SetEntryPoint();
// currently visible objects at player client
typedef std::unordered_set<uint64> ClientGUIDs;
ClientGUIDs m_clientGUIDs;
GuidUnorderedSet m_clientGUIDs;
std::vector<Unit*> m_newVisible; // pussywizard
bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); }
[[nodiscard]] bool HaveAtClient(uint64 guid) const { return guid == GetGUID() || m_clientGUIDs.find(guid) != m_clientGUIDs.end(); }
[[nodiscard]] bool HaveAtClient(ObjectGuid guid) const { return guid == GetGUID() || m_clientGUIDs.find(guid) != m_clientGUIDs.end(); }
[[nodiscard]] bool IsNeverVisible() const override;
@@ -2560,8 +2560,8 @@ public:
bool isDebugAreaTriggers;
void ClearWhisperWhiteList() { WhisperList.clear(); }
void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); }
bool IsInWhisperWhiteList(uint64 guid);
void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); }
bool IsInWhisperWhiteList(ObjectGuid guid);
bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override;
bool SetCanFly(bool apply, bool packetOnly = false) override;
@@ -2583,18 +2583,18 @@ public:
[[nodiscard]] bool HasPendingSpectatorForBG(uint32 bgInstanceId) const { return m_pendingSpectatorForBG == bgInstanceId; }
void SetPendingSpectatorInviteInstanceId(uint32 bgInstanceId) { m_pendingSpectatorInviteInstanceId = bgInstanceId; }
[[nodiscard]] uint32 GetPendingSpectatorInviteInstanceId() const { return m_pendingSpectatorInviteInstanceId; }
bool HasReceivedSpectatorResetFor(uint32 guid) { return m_receivedSpectatorResetFor.find(guid) != m_receivedSpectatorResetFor.end(); }
bool HasReceivedSpectatorResetFor(ObjectGuid guid) { return m_receivedSpectatorResetFor.find(guid) != m_receivedSpectatorResetFor.end(); }
void ClearReceivedSpectatorResetFor() { m_receivedSpectatorResetFor.clear(); }
void AddReceivedSpectatorResetFor(uint32 guid) { m_receivedSpectatorResetFor.insert(guid); }
void RemoveReceivedSpectatorResetFor(uint32 guid) { m_receivedSpectatorResetFor.erase(guid); }
void AddReceivedSpectatorResetFor(ObjectGuid guid) { m_receivedSpectatorResetFor.insert(guid); }
void RemoveReceivedSpectatorResetFor(ObjectGuid guid) { m_receivedSpectatorResetFor.erase(guid); }
uint32 m_pendingSpectatorForBG;
uint32 m_pendingSpectatorInviteInstanceId;
std::set<uint32> m_receivedSpectatorResetFor;
GuidSet m_receivedSpectatorResetFor;
// Dancing Rune weapon
void setRuneWeaponGUID(uint64 guid) { m_drwGUID = guid; };
uint64 getRuneWeaponGUID() { return m_drwGUID; };
uint64 m_drwGUID;
void setRuneWeaponGUID(ObjectGuid guid) { m_drwGUID = guid; };
ObjectGuid getRuneWeaponGUID() { return m_drwGUID; };
ObjectGuid m_drwGUID;
[[nodiscard]] bool CanSeeDKPet() const { return m_ExtraFlags & PLAYER_EXTRA_SHOW_DK_PET; }
void SetShowDKPet(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_SHOW_DK_PET; else m_ExtraFlags &= ~PLAYER_EXTRA_SHOW_DK_PET; };
@@ -2682,7 +2682,7 @@ protected:
QuestSet m_monthlyquests;
SeasonalEventQuestMap m_seasonalquests;
uint64 m_divider;
ObjectGuid m_divider;
uint32 m_ingametime;
/*********************************************************/
@@ -2755,7 +2755,7 @@ protected:
time_t m_lastHonorUpdateTime;
void outDebugValues() const;
uint64 m_lootGuid;
ObjectGuid m_lootGuid;
TeamId m_team;
uint32 m_nextSave; // pussywizard
@@ -2778,7 +2778,7 @@ protected:
uint32 m_ExtraFlags;
uint64 m_comboTarget;
ObjectGuid m_comboTarget;
int8 m_comboPoints;
QuestStatusMap m_QuestStatus;
@@ -2823,7 +2823,7 @@ protected:
ItemDurationList m_itemSoulboundTradeable;
std::mutex m_soulboundTradableLock;
uint64 m_resurrectGUID;
ObjectGuid m_resurrectGUID;
uint32 m_resurrectMap;
float m_resurrectX, m_resurrectY, m_resurrectZ;
uint32 m_resurrectHealth, m_resurrectMana;
@@ -2915,7 +2915,7 @@ private:
Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update);
Item* _LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields);
typedef std::set<uint32> RefundableItemsSet;
typedef GuidSet RefundableItemsSet;
RefundableItemsSet m_refundableItems;
void SendRefundInfo(Item* item);
void RefundItem(Item* item);
@@ -2984,6 +2984,8 @@ private:
FlyByCameraCollection* m_cinematicCamera;
Position m_remoteSightPosition;
Creature* m_CinematicObject;
WorldLocation _corpseLocation;
};
void AddItemsSetItem(Player* player, Item* item);

View File

@@ -26,7 +26,7 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) const
return counter;
}
bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag)
bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
{
// check client limits
if (GetNumberOfSocialsWithFlag(flag) >= (((flag & SOCIAL_FLAG_FRIEND) != 0) ? SOCIALMGR_FRIEND_LIMIT : SOCIALMGR_IGNORE_LIMIT))
@@ -40,8 +40,8 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS);
stmt->setUInt8(0, itr->second.Flags);
stmt->setUInt32(1, GetPlayerGUID());
stmt->setUInt32(2, friendGuid);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -51,8 +51,8 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);
stmt->setUInt32(0, GetPlayerGUID());
stmt->setUInt32(1, friendGuid);
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
stmt->setUInt32(1, friendGuid.GetCounter());
stmt->setUInt8(2, flag);
CharacterDatabase.Execute(stmt);
@@ -60,7 +60,7 @@ bool PlayerSocial::AddToSocialList(uint64 friendGuid, SocialFlag flag)
return true;
}
void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag)
void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
{
auto itr = m_playerSocialMap.find(friendGuid);
if (itr == m_playerSocialMap.end()) // not exist
@@ -72,8 +72,8 @@ void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SOCIAL);
stmt->setUInt32(0, GetPlayerGUID());
stmt->setUInt32(1, friendGuid);
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
stmt->setUInt32(1, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
@@ -84,14 +84,14 @@ void PlayerSocial::RemoveFromSocialList(uint64 friendGuid, SocialFlag flag)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_CHARACTER_SOCIAL_FLAGS);
stmt->setUInt8(0, flag);
stmt->setUInt32(1, GetPlayerGUID());
stmt->setUInt32(2, friendGuid);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
}
}
void PlayerSocial::SetFriendNote(uint64 friendGuid, std::string note)
void PlayerSocial::SetFriendNote(ObjectGuid friendGuid, std::string note)
{
auto itr = m_playerSocialMap.find(friendGuid);
if (itr == m_playerSocialMap.end()) // not exist
@@ -102,8 +102,8 @@ void PlayerSocial::SetFriendNote(uint64 friendGuid, std::string note)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE);
stmt->setString(0, note);
stmt->setUInt32(1, GetPlayerGUID());
stmt->setUInt32(2, friendGuid);
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
stmt->setUInt32(2, friendGuid.GetCounter());
CharacterDatabase.Execute(stmt);
@@ -145,7 +145,7 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
sSocialMgr->GetFriendInfo(player, itr.first, friendInfo);
data << uint64(itr.first); // player guid
data << itr.first; // player guid
data << uint32(contactFlags); // player flag (0x1 = Friend, 0x2 = Ignored, 0x4 = Muted)
data << friendInfo.Note; // string note
if (contactFlags & SOCIAL_FLAG_FRIEND) // if IsFriend()
@@ -165,7 +165,7 @@ void PlayerSocial::SendSocialList(Player* player, uint32 flags)
LOG_DEBUG("network", "WORLD: Sent SMSG_CONTACT_LIST");
}
bool PlayerSocial::_checkContact(uint64 guid, SocialFlag flags) const
bool PlayerSocial::_checkContact(ObjectGuid guid, SocialFlag flags) const
{
const auto& itr = m_playerSocialMap.find(guid);
if (itr != m_playerSocialMap.end())
@@ -174,12 +174,12 @@ bool PlayerSocial::_checkContact(uint64 guid, SocialFlag flags) const
return false;
}
bool PlayerSocial::HasFriend(uint64 friend_guid) const
bool PlayerSocial::HasFriend(ObjectGuid friend_guid) const
{
return _checkContact(friend_guid, SOCIAL_FLAG_FRIEND);
}
bool PlayerSocial::HasIgnore(uint64 ignore_guid) const
bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid) const
{
return _checkContact(ignore_guid, SOCIAL_FLAG_IGNORED);
}
@@ -198,7 +198,7 @@ SocialMgr* SocialMgr::instance()
return &instance;
}
void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& friendInfo)
void SocialMgr::GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo)
{
if (!player)
return;
@@ -208,7 +208,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& fri
friendInfo.Level = 0;
friendInfo.Class = 0;
Player* pFriend = ObjectAccessor::FindPlayerInOrOutOfWorld(friendGUID);
Player* pFriend = ObjectAccessor::FindConnectedPlayer(friendGUID);
if (!pFriend || AccountMgr::IsGMAccount(pFriend->GetSession()->GetSecurity()))
return;
@@ -236,14 +236,14 @@ void SocialMgr::GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& fri
}
}
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint64 guid, WorldPacket* data)
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, ObjectGuid guid, WorldPacket* data)
{
data->Initialize(SMSG_FRIEND_STATUS, 9);
*data << uint8(result);
*data << uint64(guid);
*data << guid;
}
void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, uint64 friendGuid, bool broadcast)
void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friendGuid, bool broadcast)
{
FriendInfo fi;
GetFriendInfo(player, friendGuid, fi);
@@ -287,16 +287,15 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
TeamId teamId = player->GetTeamId();
AccountTypes security = player->GetSession()->GetSecurity();
uint32 guid = player->GetGUIDLow();
bool allowTwoSideWhoList = sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST));
for (auto const& itr : m_socialMap)
{
auto const& itr2 = itr.second.m_playerSocialMap.find(guid);
auto const& itr2 = itr.second.m_playerSocialMap.find(player->GetGUID());
if (itr2 != itr.second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
{
Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr.first, 0, HIGHGUID_PLAYER));
Player* pFriend = ObjectAccessor::FindPlayer(itr.first);
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all
@@ -306,7 +305,7 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
}
}
PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint64 guid)
PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid guid)
{
PlayerSocial* social = &m_socialMap[guid];
social->SetPlayerGUID(guid);
@@ -318,7 +317,7 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, uint64 guid)
{
Field* fields = result->Fetch();
auto friendGuid = fields[0].GetUInt32();
auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32());
auto flags = fields[1].GetUInt8();
auto note = fields[2].GetString();

View File

@@ -93,22 +93,22 @@ class PlayerSocial
public:
PlayerSocial();
// adding/removing
bool AddToSocialList(uint64 friend_guid, SocialFlag flag);
void RemoveFromSocialList(uint64 friend_guid, SocialFlag flag);
void SetFriendNote(uint64 friendGuid, std::string note);
bool AddToSocialList(ObjectGuid friend_guid, SocialFlag flag);
void RemoveFromSocialList(ObjectGuid friend_guid, SocialFlag flag);
void SetFriendNote(ObjectGuid friendGuid, std::string note);
// Packet send's
void SendSocialList(Player* player, uint32 flags);
// Misc
bool HasFriend(uint64 friend_guid) const;
bool HasIgnore(uint64 ignore_guid) const;
uint64 GetPlayerGUID() const { return m_playerGUID; }
void SetPlayerGUID(uint64 guid) { m_playerGUID = guid; }
bool HasFriend(ObjectGuid friend_guid) const;
bool HasIgnore(ObjectGuid ignore_guid) const;
ObjectGuid GetPlayerGUID() const { return m_playerGUID; }
void SetPlayerGUID(ObjectGuid guid) { m_playerGUID = guid; }
uint32 GetNumberOfSocialsWithFlag(SocialFlag flag) const;
private:
bool _checkContact(uint64 guid, SocialFlag flags) const;
typedef std::map<uint32, FriendInfo> PlayerSocialMap;
bool _checkContact(ObjectGuid guid, SocialFlag flags) const;
typedef std::map<ObjectGuid, FriendInfo> PlayerSocialMap;
PlayerSocialMap m_playerSocialMap;
uint64 m_playerGUID;
ObjectGuid m_playerGUID;
};
class SocialMgr
@@ -120,16 +120,16 @@ class SocialMgr
public:
static SocialMgr* instance();
// Misc
void RemovePlayerSocial(uint64 guid) { m_socialMap.erase(guid); }
static void GetFriendInfo(Player* player, uint64 friendGUID, FriendInfo& friendInfo);
void RemovePlayerSocial(ObjectGuid guid) { m_socialMap.erase(guid); }
static void GetFriendInfo(Player* player, ObjectGuid friendGUID, FriendInfo& friendInfo);
// Packet management
void MakeFriendStatusPacket(FriendsResult result, uint64 friend_guid, WorldPacket* data);
void SendFriendStatus(Player* player, FriendsResult result, uint64 friend_guid, bool broadcast);
void MakeFriendStatusPacket(FriendsResult result, ObjectGuid friend_guid, WorldPacket* data);
void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast);
void BroadcastToFriendListers(Player* player, WorldPacket* packet);
// Loading
PlayerSocial* LoadFromDB(PreparedQueryResult result, uint64 guid);
PlayerSocial* LoadFromDB(PreparedQueryResult result, ObjectGuid guid);
private:
typedef std::map<uint32, PlayerSocial> SocialMap;
typedef std::map<ObjectGuid, PlayerSocial> SocialMap;
SocialMap m_socialMap;
};

View File

@@ -15,7 +15,7 @@
#include "Totem.h"
#include "WorldPacket.h"
Totem::Totem(SummonPropertiesEntry const* properties, uint64 owner) : Minion(properties, owner, false)
Totem::Totem(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false)
{
m_unitTypeMask |= UNIT_MASK_TOTEM;
m_duration = 0;
@@ -45,13 +45,13 @@ void Totem::InitStats(uint32 duration)
{
// client requires SMSG_TOTEM_CREATED to be sent before adding to world and before removing old totem
// Xinef: Set level for Unit totems
if (Unit* owner = ObjectAccessor::FindUnit(m_owner))
if (Unit* owner = ObjectAccessor::GetUnit(*this, m_owner))
{
if (owner->GetTypeId() == TYPEID_PLAYER && m_Properties->Slot >= SUMMON_SLOT_TOTEM && m_Properties->Slot < MAX_TOTEM_SLOT)
{
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
data << uint8(m_Properties->Slot - 1);
data << uint64(GetGUID());
data << GetGUID();
data << uint32(duration);
data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL));
owner->ToPlayer()->SendDirectMessage(&data);
@@ -109,7 +109,7 @@ void Totem::UnSummon(uint32 msTime)
{
if (owner->m_SummonSlot[i] == GetGUID())
{
owner->m_SummonSlot[i] = 0;
owner->m_SummonSlot[i].Clear();
break;
}
}

View File

@@ -26,7 +26,7 @@ constexpr uint32 SPELL_CYCLONE = 33786;
class Totem : public Minion
{
public:
explicit Totem(SummonPropertiesEntry const* properties, uint64 owner);
explicit Totem(SummonPropertiesEntry const* properties, ObjectGuid owner);
~Totem() override {};
void Update(uint32 time) override;
void InitStats(uint32 duration) override;

View File

@@ -32,7 +32,7 @@ MotionTransport::~MotionTransport()
UnloadStaticPassengers();
}
bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
bool MotionTransport::CreateMoTrans(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
{
Relocate(x, y, z, ang);
@@ -43,7 +43,7 @@ bool MotionTransport::CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid,
return false;
}
Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT);
Object::_Create(guidlow, 0, HighGuid::Mo_Transport);
GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
@@ -292,7 +292,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
{
passenger->SetTransport(nullptr);
passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
passenger->m_movementInfo.transport.guid = 0;
passenger->m_movementInfo.transport.guid.Clear();
passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
if (passenger->ToUnit())
{
@@ -302,7 +302,7 @@ void MotionTransport::RemovePassenger(WorldObject* passenger, bool withAll)
}
}
Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* data)
Creature* MotionTransport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data)
{
Map* map = GetMap();
Creature* creature = new Creature();
@@ -333,7 +333,8 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d
if (!creature->IsPositionValid())
{
LOG_ERROR("server", "Creature (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUIDLow(), creature->GetEntry(), creature->GetPositionX(), creature->GetPositionY());
LOG_ERROR("server", "Creature (%s) not created. Suggested coordinates aren't valid (X: %f Y: %f)",
creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY());
delete creature;
return nullptr;
}
@@ -349,7 +350,7 @@ Creature* MotionTransport::CreateNPCPassenger(uint32 guid, CreatureData const* d
return creature;
}
GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const* data)
GameObject* MotionTransport::CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data)
{
Map* map = GetMap();
GameObject* go = new GameObject();
@@ -374,7 +375,8 @@ GameObject* MotionTransport::CreateGOPassenger(uint32 guid, GameObjectData const
if (!go->IsPositionValid())
{
LOG_ERROR("server", "GameObject (guidlow %d, entry %d) not created. Suggested coordinates aren't valid (X: %f Y: %f)", go->GetGUIDLow(), go->GetEntry(), go->GetPositionX(), go->GetPositionY());
LOG_ERROR("server", "GameObject (%s) not created. Suggested coordinates aren't valid (X: %f Y: %f)",
go->GetGUID().ToString().c_str(), go->GetPositionX(), go->GetPositionY());
delete go;
return nullptr;
}
@@ -660,7 +662,7 @@ StaticTransport::~StaticTransport()
ASSERT(_passengers.empty());
}
bool StaticTransport::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
bool StaticTransport::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
{
ASSERT(map);
SetMap(map);
@@ -690,7 +692,7 @@ bool StaticTransport::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 ph
return false;
}
Object::_Create(guidlow, 0, HIGHGUID_TRANSPORT);
Object::_Create(guidlow, 0, HighGuid::Transport);
m_goInfo = goinfo;
@@ -970,7 +972,7 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll)
{
passenger->SetTransport(nullptr);
passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
passenger->m_movementInfo.transport.guid = 0;
passenger->m_movementInfo.transport.guid.Clear();
passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
}
}

View File

@@ -35,12 +35,12 @@ protected:
class MotionTransport : public Transport
{
friend MotionTransport* TransportMgr::CreateTransport(uint32, uint32, Map*);
friend MotionTransport* TransportMgr::CreateTransport(uint32, ObjectGuid::LowType, Map*);
MotionTransport();
public:
~MotionTransport() override;
bool CreateMoTrans(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress);
bool CreateMoTrans(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress);
void CleanupsBeforeDelete(bool finalCleanup = true) override;
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override;
@@ -50,8 +50,8 @@ public:
void AddPassenger(WorldObject* passenger, bool withAll = false) override;
void RemovePassenger(WorldObject* passenger, bool withAll = false) override;
Creature* CreateNPCPassenger(uint32 guid, CreatureData const* data);
GameObject* CreateGOPassenger(uint32 guid, GameObjectData const* data);
Creature* CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data);
GameObject* CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const* data);
void LoadStaticPassengers();
PassengerSet const& GetStaticPassengers() const { return _staticPassengers; }
@@ -102,7 +102,7 @@ public:
StaticTransport();
~StaticTransport() override;
bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0) override;
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0) override;
void CleanupsBeforeDelete(bool finalCleanup = true) override;
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override;

File diff suppressed because it is too large Load Diff

View File

@@ -1039,13 +1039,13 @@ uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missC
struct RedirectThreatInfo
{
RedirectThreatInfo() { }
uint64 _targetGUID{0};
ObjectGuid _targetGUID;
uint32 _threatPct{0};
[[nodiscard]] uint64 GetTargetGUID() const { return _targetGUID; }
[[nodiscard]] ObjectGuid GetTargetGUID() const { return _targetGUID; }
[[nodiscard]] uint32 GetThreatPct() const { return _threatPct; }
void Set(uint64 guid, uint32 pct)
void Set(ObjectGuid guid, uint32 pct)
{
_targetGUID = guid;
_threatPct = pct;
@@ -1235,8 +1235,8 @@ public:
void SetForcedSpell(uint32 id) { _forcedSpellId = id; }
int32 GetForcedSpell() { return _forcedSpellId; }
void SetForcedTargetGUID(uint64 guid) { _forcedTargetGUID = guid; }
uint64 GetForcedTarget() { return _forcedTargetGUID; }
void SetForcedTargetGUID(ObjectGuid guid = ObjectGuid::Empty) { _forcedTargetGUID = guid; }
ObjectGuid GetForcedTarget() { return _forcedTargetGUID; }
// Player react states
void SetPlayerReactState(ReactStates s) { _oldReactState = s; }
@@ -1258,7 +1258,7 @@ private:
bool _isFollowing;
bool _isReturning;
int32 _forcedSpellId;
uint64 _forcedTargetGUID;
ObjectGuid _forcedTargetGUID;
float _stayX;
float _stayY;
float _stayZ;
@@ -1400,7 +1400,7 @@ public:
typedef std::list<Aura*> AuraList;
typedef std::list<AuraApplication*> AuraApplicationList;
typedef std::list<DiminishingReturn> Diminishing;
typedef std::unordered_set<uint32> ComboPointHolderSet;
typedef GuidUnorderedSet ComboPointHolderSet;
typedef std::map<uint8, AuraApplication*> VisibleAuraMap;
@@ -1486,7 +1486,7 @@ public:
[[nodiscard]] bool CanFreeMove() const
{
return !HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT |
UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && GetOwnerGUID() == 0;
UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED) && !GetOwnerGUID();
}
[[nodiscard]] uint32 HasUnitTypeMask(uint32 mask) const { return mask & m_unitTypeMask; }
@@ -1774,22 +1774,22 @@ public:
void SendEnergizeSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype);
void EnergizeBySpell(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype);
SpellCastResult CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, uint64 originalCaster = 0);
SpellCastResult CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(Unit* victim, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(Unit* victim, uint32 spellId, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(Unit* victim, SpellInfo const* spellInfo, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastSpell(GameObject* go, uint32 spellId, bool triggered, Item* castItem = nullptr, AuraEffect* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
SpellCastResult CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty);
Aura* AddAura(uint32 spellId, Unit* target);
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
void SetAuraStack(uint32 spellId, Unit* target, uint32 stack);
void SendPlaySpellVisual(uint32 id);
void SendPlaySpellImpact(uint64 guid, uint32 id);
void SendPlaySpellImpact(ObjectGuid guid, uint32 id);
void BuildCooldownPacket(WorldPacket& data, uint8 flags, uint32 spellId, uint32 cooldown);
void BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns const& cooldowns);
@@ -1856,30 +1856,31 @@ public:
DeathState getDeathState() { return m_deathState; };
virtual void setDeathState(DeathState s, bool despawn = false); // overwrited in Creature/Player/Pet
[[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); }
void SetOwnerGUID(uint64 owner);
[[nodiscard]] uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); }
void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); }
[[nodiscard]] uint64 GetMinionGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); }
void SetMinionGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_SUMMON, guid); }
[[nodiscard]] uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); }
void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); }
[[nodiscard]] uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); }
void SetPetGUID(uint64 guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
[[nodiscard]] uint64 GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
void SetCritterGUID(uint64 guid) { SetUInt64Value(UNIT_FIELD_CRITTER, guid); }
[[nodiscard]] uint64 GetCritterGUID() const { return GetUInt64Value(UNIT_FIELD_CRITTER); }
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); }
void SetOwnerGUID(ObjectGuid owner);
[[nodiscard]] ObjectGuid GetCreatorGUID() const { return GetGuidValue(UNIT_FIELD_CREATEDBY); }
void SetCreatorGUID(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); }
[[nodiscard]] ObjectGuid GetMinionGUID() const { return GetGuidValue(UNIT_FIELD_SUMMON); }
void SetMinionGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_SUMMON, guid); }
[[nodiscard]] ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); }
void SetCharmerGUID(ObjectGuid owner) { SetGuidValue(UNIT_FIELD_CHARMEDBY, owner); }
[[nodiscard]] ObjectGuid GetCharmGUID() const { return GetGuidValue(UNIT_FIELD_CHARM); }
void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
[[nodiscard]] ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); }
[[nodiscard]] ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); }
[[nodiscard]] bool IsControlledByPlayer() const { return m_ControlledByPlayer; }
[[nodiscard]] bool IsCreatedByPlayer() const { return m_CreatedByPlayer; }
[[nodiscard]] uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
[[nodiscard]] uint64 GetCharmerOrOwnerOrOwnGUID() const
[[nodiscard]] ObjectGuid GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); }
[[nodiscard]] ObjectGuid GetCharmerOrOwnerOrOwnGUID() const
{
if (uint64 guid = GetCharmerOrOwnerGUID())
if (ObjectGuid guid = GetCharmerOrOwnerGUID())
return guid;
return GetGUID();
}
[[nodiscard]] bool IsCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); }
[[nodiscard]] bool IsCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGUID().IsPlayer(); }
[[nodiscard]] Player* GetSpellModOwner() const;
@@ -1912,9 +1913,9 @@ public:
[[nodiscard]] Unit* GetFirstControlled() const;
void RemoveAllControlled();
[[nodiscard]] bool IsCharmed() const { return GetCharmerGUID() != 0; }
[[nodiscard]] bool IsCharmed() const { return GetCharmerGUID(); }
[[nodiscard]] bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); }
[[nodiscard]] bool isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && IS_PLAYER_GUID(GetCharmerGUID()); }
[[nodiscard]] bool isPossessedByPlayer() const { return HasUnitState(UNIT_STATE_POSSESSED) && GetCharmerGUID().IsPlayer(); }
[[nodiscard]] bool isPossessing() const
{
if (Unit* u = GetCharm())
@@ -1942,7 +1943,7 @@ public:
bool InitTamedPet(Pet* pet, uint8 level, uint32 spell_id);
// aura apply/remove helpers - you should better not use these
Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, uint64 casterGUID = 0, bool periodicReset = false);
Aura* _TryStackingOrRefreshingExistingAura(SpellInfo const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = nullptr, Item* castItem = nullptr, ObjectGuid casterGUID = ObjectGuid::Empty, bool periodicReset = false);
void _AddAura(UnitAura* aura, Unit* caster);
AuraApplication* _CreateAuraApplication(Aura* aura, uint8 effMask);
void _ApplyAuraEffect(Aura* aura, uint8 effIndex);
@@ -1959,17 +1960,17 @@ public:
[[nodiscard]] AuraMap const& GetOwnedAuras() const { return m_ownedAuras; }
void RemoveOwnedAura(AuraMap::iterator& i, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveOwnedAura(Aura* aura, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
Aura* GetOwnedAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, Aura* except = nullptr) const;
Aura* GetOwnedAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, Aura* except = nullptr) const;
// m_appliedAuras container management
AuraApplicationMap& GetAppliedAuras() { return m_appliedAuras; }
[[nodiscard]] AuraApplicationMap const& GetAppliedAuras() const { return m_appliedAuras; }
void RemoveAura(AuraApplicationMap::iterator& i, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(AuraApplication* aurApp, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAura(Aura* aur, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
@@ -1981,16 +1982,16 @@ public:
void RemoveAppliedAuras(uint32 spellId, std::function<bool(AuraApplication const*)> const& check);
void RemoveOwnedAuras(uint32 spellId, std::function<bool(Aura const*)> const& check);
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAuraFromStack(uint32 spellId, uint64 casterGUID = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1);
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer);
void RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid);
void RemoveAurasByType(AuraType auraType, uint64 casterGUID = 0, Aura* except = nullptr, bool negative = true, bool positive = true);
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAuraFromStack(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, ObjectGuid casterGUID, Unit* dispeller, uint8 chargesRemoved = 1);
void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGUID, Unit* stealer);
void RemoveAurasDueToItemSpell(uint32 spellId, ObjectGuid castItemGuid);
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID = ObjectGuid::Empty, Aura* except = nullptr, bool negative = true, bool positive = true);
void RemoveNotOwnSingleTargetAuras();
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except = 0);
void RemoveAurasWithAttribute(uint32 flags);
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID);
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID);
void RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemode = AURA_REMOVE_BY_DEFAULT, uint32 except = 0);
void RemoveMovementImpairingAuras(bool withRoot);
void RemoveAurasByShapeShift();
@@ -2003,7 +2004,7 @@ public:
void RemoveAllAurasExceptType(AuraType type);
//void RemoveAllAurasExceptType(AuraType type1, AuraType type2); // pussywizard: replaced with RemoveEvadeAuras()
void RemoveEvadeAuras();
void DelayOwnedAuras(uint32 spellId, uint64 caster, int32 delaytime);
void DelayOwnedAuras(uint32 spellId, ObjectGuid caster, int32 delaytime);
void _RemoveAllAuraStatMods();
void _ApplyAllAuraStatMods();
@@ -2012,37 +2013,37 @@ public:
AuraList& GetSingleCastAuras() { return m_scAuras; }
[[nodiscard]] AuraList const& GetSingleCastAuras() const { return m_scAuras; }
[[nodiscard]] AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const;
[[nodiscard]] AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const;
[[nodiscard]] AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const;
[[nodiscard]] AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, ObjectGuid casterGUID = ObjectGuid::Empty) const;
[[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags
[[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID = 0) const;
[[nodiscard]] AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, ObjectGuid casterGUID = ObjectGuid::Empty) const;
[[nodiscard]] AuraEffect* GetAuraEffectDummy(uint32 spellid) const;
[[nodiscard]] inline AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const { return GetAuraEffect(SPELL_AURA_DUMMY, name, iconId, effIndex);}
AuraApplication* GetAuraApplication(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const;
[[nodiscard]] Aura* GetAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const;
AuraApplication* GetAuraApplication(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const;
[[nodiscard]] Aura* GetAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
AuraApplication* GetAuraApplicationOfRankedSpell(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const;
[[nodiscard]] Aura* GetAuraOfRankedSpell(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const;
AuraApplication* GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0, AuraApplication* except = nullptr) const;
[[nodiscard]] Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList);
[[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, uint64 caster = 0) const;
[[nodiscard]] bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const;
[[nodiscard]] uint32 GetAuraCount(uint32 spellId) const;
[[nodiscard]] bool HasAura(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0) const;
[[nodiscard]] bool HasAura(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint8 reqEffMask = 0) const;
[[nodiscard]] bool HasAuraType(AuraType auraType) const;
[[nodiscard]] bool HasAuraTypeWithCaster(AuraType auratype, uint64 caster) const;
[[nodiscard]] bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const;
[[nodiscard]] bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const;
bool HasAuraTypeWithAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const;
[[nodiscard]] bool HasAuraTypeWithValue(AuraType auratype, int32 value) const;
bool HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid = 0);
bool HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid = ObjectGuid::Empty);
[[nodiscard]] bool HasVisibleAuraType(AuraType auraType) const;
bool HasNegativeAuraWithAttribute(uint32 flag, uint64 guid = 0);
bool HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid = ObjectGuid::Empty);
[[nodiscard]] bool HasAuraWithMechanic(uint32 mechanicMask) const;
AuraEffect* IsScriptOverriden(SpellInfo const* spell, int32 script) const;
uint32 GetDiseasesByCaster(uint64 casterGUID, uint8 mode = 0);
[[nodiscard]] uint32 GetDoTsByCaster(uint64 casterGUID) const;
uint32 GetDiseasesByCaster(ObjectGuid casterGUID, uint8 mode = 0);
[[nodiscard]] uint32 GetDoTsByCaster(ObjectGuid casterGUID) const;
[[nodiscard]] int32 GetTotalAuraModifierAreaExclusive(AuraType auratype) const;
[[nodiscard]] int32 GetTotalAuraModifier(AuraType auratype) const;
@@ -2109,8 +2110,8 @@ public:
[[nodiscard]] Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
[[nodiscard]] int32 GetCurrentSpellCastTime(uint32 spell_id) const;
uint64 m_SummonSlot[MAX_SUMMON_SLOT];
uint64 m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT];
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
[[nodiscard]] ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); }
void SetShapeshiftForm(ShapeshiftForm form)
@@ -2327,14 +2328,14 @@ public:
void DisableRotate(bool apply);
void DisableSpline();
void AddComboPointHolder(uint32 lowguid) { m_ComboPointHolders.insert(lowguid); }
void RemoveComboPointHolder(uint32 lowguid) { m_ComboPointHolders.erase(lowguid); }
void AddComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.insert(lowguid); }
void RemoveComboPointHolder(ObjectGuid lowguid) { m_ComboPointHolders.erase(lowguid); }
void ClearComboPointHolders();
///----------Pet responses methods-----------------
void SendPetActionFeedback (uint8 msg);
void SendPetTalk (uint32 pettalk);
void SendPetAIReaction(uint64 guid);
void SendPetAIReaction(ObjectGuid guid);
///----------End of Pet responses methods----------
void propagateSpeedChange() { GetMotionMaster()->propagateSpeedChange(); }
@@ -2372,8 +2373,8 @@ public:
uint32 GetModelForTotem(PlayerTotemType totemType);
// Redirect Threat
void SetRedirectThreat(uint64 guid, uint32 pct) { _redirectThreatInfo.Set(guid, pct); }
void ResetRedirectThreat() { SetRedirectThreat(0, 0); }
void SetRedirectThreat(ObjectGuid guid, uint32 pct) { _redirectThreatInfo.Set(guid, pct); }
void ResetRedirectThreat() { SetRedirectThreat(ObjectGuid::Empty, 0); }
void ModifyRedirectThreat(int32 amount) { _redirectThreatInfo.ModifyThreatPct(amount); }
uint32 GetRedirectThreatPercent() { return _redirectThreatInfo.GetThreatPct(); }
[[nodiscard]] Unit* GetRedirectThreatTarget() const;
@@ -2386,7 +2387,7 @@ public:
bool IsOnVehicle(const Unit* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); }
[[nodiscard]] Unit* GetVehicleBase() const;
[[nodiscard]] Creature* GetVehicleCreatureBase() const;
[[nodiscard]] uint64 GetTransGUID() const override;
[[nodiscard]] ObjectGuid GetTransGUID() const override;
/// Returns the transport this unit is on directly (if on vehicle and transport, return vehicle)
[[nodiscard]] TransportBase* GetDirectTransport() const;
@@ -2480,8 +2481,8 @@ public:
int32 CalculateAOEDamageReduction(int32 damage, uint32 schoolMask, Unit* caster) const;
[[nodiscard]] uint64 GetTarget() const { return GetUInt64Value(UNIT_FIELD_TARGET); }
virtual void SetTarget(uint64 /*guid*/) = 0;
[[nodiscard]] ObjectGuid GetTarget() const { return GetGuidValue(UNIT_FIELD_TARGET); }
virtual void SetTarget(ObjectGuid /*guid*/ = ObjectGuid::Empty) = 0;
void SetInstantCast(bool set) { _instantCast = set; }
[[nodiscard]] bool CanInstantCast() const { return _instantCast; }
@@ -2524,7 +2525,7 @@ protected:
typedef std::list<DynamicObject*> DynObjectList;
DynObjectList m_dynObj;
typedef std::list<uint64> GameObjectList;
typedef GuidList GameObjectList;
GameObjectList m_gameObj;
uint32 m_transform;
@@ -2560,7 +2561,7 @@ protected:
int32 m_regenTimer;
ThreatManager m_ThreatManager;
typedef std::map<uint64, float> CharmThreatMap;
typedef std::map<ObjectGuid, float> CharmThreatMap;
CharmThreatMap _charmThreatInfo;
Vehicle* m_vehicle;
@@ -2680,23 +2681,23 @@ namespace acore
class ConflagrateAuraStateDelayEvent : public BasicEvent
{
public:
ConflagrateAuraStateDelayEvent(uint64 ownerGUID, uint64 casterGUID) : BasicEvent(), m_owner(ownerGUID), m_caster(casterGUID) { }
ConflagrateAuraStateDelayEvent(Unit* owner, ObjectGuid casterGUID) : BasicEvent(), m_owner(owner), m_casterGUID(casterGUID) { }
bool Execute(uint64 e_time, uint32 p_time) override;
private:
uint64 m_owner;
uint64 m_caster;
Unit* m_owner;
ObjectGuid m_casterGUID;
};
class RedirectSpellEvent : public BasicEvent
{
public:
RedirectSpellEvent(Unit& self, uint64 auraOwnerGUID, AuraEffect* auraEffect) : _self(self), _auraOwnerGUID(auraOwnerGUID), _auraEffect(auraEffect) { }
RedirectSpellEvent(Unit& self, ObjectGuid auraOwnerGUID, AuraEffect* auraEffect) : _self(self), _auraOwnerGUID(auraOwnerGUID), _auraEffect(auraEffect) { }
bool Execute(uint64 e_time, uint32 p_time) override;
protected:
Unit& _self;
uint64 _auraOwnerGUID;
ObjectGuid _auraOwnerGUID;
AuraEffect* _auraEffect;
};

View File

@@ -50,7 +50,7 @@ Vehicle::~Vehicle()
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
if (itr->second.Passenger.Guid)
{
if (Unit* unit = ObjectAccessor::FindUnit(itr->second.Passenger.Guid))
if (Unit* unit = ObjectAccessor::GetUnit(*_me, itr->second.Passenger.Guid))
{
LOG_INFO("server", "ZOMG! ~Vehicle(), unit: %s, entry: %u, typeid: %u, this_entry: %u, this_typeid: %u!", unit->GetName().c_str(), unit->GetEntry(), unit->GetTypeId(), _me ? _me->GetEntry() : 0, _me ? _me->GetTypeId() : 0);
unit->_ExitVehicle();
@@ -95,13 +95,13 @@ void Vehicle::Uninstall()
/// @Prevent recursive uninstall call. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)
if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
{
LOG_ERROR("server", "Vehicle GuidLow: %u, Entry: %u attempts to uninstall, but already has STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry());
LOG_ERROR("server", "Vehicle %s attempts to uninstall, but already has STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString().c_str());
return;
}
_status = STATUS_UNINSTALLING;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Vehicle::Uninstall Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow());
LOG_DEBUG("vehicles", "Vehicle::Uninstall %s", _me->GetGUID().ToString().c_str());
#endif
RemoveAllPassengers();
@@ -112,7 +112,7 @@ void Vehicle::Uninstall()
void Vehicle::Reset(bool evading /*= false*/)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Vehicle::Reset Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow());
LOG_DEBUG("vehicles", "Vehicle::Reset: %s", _me->GetGUID().ToString().c_str());
#endif
if (_me->GetTypeId() == TYPEID_PLAYER)
{
@@ -154,7 +154,7 @@ void Vehicle::ApplyAllImmunities()
//_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_UNATTACKABLE, true);
_me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_SHIELD, true);
_me->ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_IMMUNE_SHIELD, true);
if (_me->GetZoneId() == BATTLEFIELD_WG_ZONEID || _me->ToCreature()->GetDBTableGUIDLow() || (_me->FindMap() && _me->FindMap()->Instanceable()))
if (_me->GetZoneId() == BATTLEFIELD_WG_ZONEID || _me->ToCreature()->GetSpawnId() || (_me->FindMap() && _me->FindMap()->Instanceable()))
_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_SCHOOL_ABSORB, true);
// ... Resistance, Split damage, Change stats ...
@@ -198,7 +198,7 @@ void Vehicle::ApplyAllImmunities()
void Vehicle::RemoveAllPassengers()
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. Entry: %u, GuidLow: %u", _creatureEntry, _me->GetGUIDLow());
LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. %s", _me->GetGUID().ToString().c_str());
#endif
// Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle
@@ -263,8 +263,8 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
/// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)
if (_status == STATUS_UNINSTALLING)
{
LOG_ERROR("server", "Vehicle GuidLow: %u, Entry: %u attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUIDLow(), _me->GetEntry(), entry, (int32)seatId);
LOG_ERROR("server", "Vehicle %s attempts to install accessory Entry: %u on seat %d with STATUS_UNINSTALLING! "
"Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString().c_str(), entry, (int32)seatId);
return;
}
@@ -310,7 +310,8 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
if (_status == STATUS_UNINSTALLING)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %i", unit->GetGUIDLow(), unit->GetEntry(), _me->GetGUIDLow(), _me->GetEntry(), (int32)seatId);
LOG_DEBUG("vehicles", "Passenger %s, attempting to board vehicle %s during uninstall! SeatId: %i",
unit->GetGUID().ToString().c_str(), _me->GetGUID().ToString().c_str(), (int32)seatId);
#endif
return false;
}
@@ -339,14 +340,15 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid))
passenger->ExitVehicle();
seat->second.Passenger.Guid = 0;
seat->second.Passenger.Guid.Clear();
}
ASSERT(seat->second.IsEmpty());
}
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Unit %s enter vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first);
LOG_DEBUG("vehicles", "Unit %s enter vehicle entry %u id %u (%s) seat %d",
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString().c_str(), (int32)seat->first);
#endif
seat->second.Passenger.Guid = unit->GetGUID();
@@ -457,7 +459,8 @@ void Vehicle::RemovePassenger(Unit* unit)
return;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Unit %s exit vehicle entry %u id %u dbguid %u seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first);
LOG_DEBUG("vehicles", "Unit %s exit vehicle entry %u id %u (%s) seat %d",
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString().c_str(), (int32)seat->first);
#endif
if (seat->second.SeatInfo->CanEnterOrExit() && ++_usableSeatNum)
@@ -525,7 +528,7 @@ void Vehicle::Dismiss()
return;
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("vehicles", "Vehicle::Dismiss Entry: %u, GuidLow %u", _creatureEntry, _me->GetGUIDLow());
LOG_DEBUG("vehicles", "Vehicle::Dismiss %s", _me->GetGUID().ToString().c_str());
#endif
Uninstall();
GetBase()->ToCreature()->DespawnOrUnsummon();

View File

@@ -54,12 +54,12 @@ enum VehicleNPCs
struct PassengerInfo
{
uint64 Guid;
ObjectGuid Guid;
bool IsUnselectable;
void Reset()
{
Guid = 0;
Guid.Clear();
IsUnselectable = false;
}
};