mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[10812] Use ObjectGuid for corpse owner guid.
Still exist 9 GUID_LOPART uses in code.
This commit is contained in:
parent
b305f203b9
commit
0a964e43a9
7 changed files with 25 additions and 24 deletions
|
|
@ -90,7 +90,7 @@ bool Corpse::Create( uint32 guidlow, Player *owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetObjectScale(DEFAULT_OBJECT_SCALE);
|
SetObjectScale(DEFAULT_OBJECT_SCALE);
|
||||||
SetUInt64Value( CORPSE_FIELD_OWNER, owner->GetGUID() );
|
SetGuidValue(CORPSE_FIELD_OWNER, owner->GetObjectGuid());
|
||||||
|
|
||||||
m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
|
m_grid = MaNGOS::ComputeGridPair(GetPositionX(), GetPositionY());
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ void Corpse::SaveToDB()
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,map,time,corpse_type,instance,phaseMask) VALUES ("
|
ss << "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,map,time,corpse_type,instance,phaseMask) VALUES ("
|
||||||
<< GetGUIDLow() << ", "
|
<< GetGUIDLow() << ", "
|
||||||
<< GUID_LOPART(GetOwnerGUID()) << ", "
|
<< GetOwnerGuid().GetCounter() << ", "
|
||||||
<< GetPositionX() << ", "
|
<< GetPositionX() << ", "
|
||||||
<< GetPositionY() << ", "
|
<< GetPositionY() << ", "
|
||||||
<< GetPositionZ() << ", "
|
<< GetPositionZ() << ", "
|
||||||
|
|
@ -143,7 +143,7 @@ void Corpse::DeleteFromDB()
|
||||||
MANGOS_ASSERT(GetType() != CORPSE_BONES);
|
MANGOS_ASSERT(GetType() != CORPSE_BONES);
|
||||||
|
|
||||||
// all corpses (not bones)
|
// all corpses (not bones)
|
||||||
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%u' AND corpse_type <> '0'", GUID_LOPART(GetOwnerGUID()));
|
CharacterDatabase.PExecute("DELETE FROM corpse WHERE player = '%u' AND corpse_type <> '0'", GetOwnerGuid().GetCounter());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
|
bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
|
||||||
|
|
@ -166,7 +166,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
|
||||||
|
|
||||||
if(m_type >= MAX_CORPSE_TYPE)
|
if(m_type >= MAX_CORPSE_TYPE)
|
||||||
{
|
{
|
||||||
sLog.outError("Corpse (guidlow %d, owner %d) have wrong corpse type, not load.",GetGUIDLow(),GUID_LOPART(GetOwnerGUID()));
|
sLog.outError("%s Owner %s have wrong corpse type (%i), not load.", GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), m_type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,8 +240,8 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field *fields)
|
||||||
|
|
||||||
if(!IsPositionValid())
|
if(!IsPositionValid())
|
||||||
{
|
{
|
||||||
sLog.outError("Corpse (guidlow %d, owner %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
|
sLog.outError("%s Owner %s not created. Suggested coordinates isn't valid (X: %f Y: %f)",
|
||||||
GetGUIDLow(), GUID_LOPART(GetOwnerGUID()), GetPositionX(), GetPositionY());
|
GetGuidStr().c_str(), GetOwnerGuid().GetString().c_str(), GetPositionX(), GetPositionY());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +257,7 @@ bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint,
|
||||||
|
|
||||||
bool Corpse::IsHostileTo( Unit const* unit ) const
|
bool Corpse::IsHostileTo( Unit const* unit ) const
|
||||||
{
|
{
|
||||||
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGUID()))
|
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
|
||||||
return owner->IsHostileTo(unit);
|
return owner->IsHostileTo(unit);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -265,7 +265,7 @@ bool Corpse::IsHostileTo( Unit const* unit ) const
|
||||||
|
|
||||||
bool Corpse::IsFriendlyTo( Unit const* unit ) const
|
bool Corpse::IsFriendlyTo( Unit const* unit ) const
|
||||||
{
|
{
|
||||||
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGUID()))
|
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
|
||||||
return owner->IsFriendlyTo(unit);
|
return owner->IsFriendlyTo(unit);
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class Corpse : public WorldObject
|
||||||
void DeleteBonesFromWorld();
|
void DeleteBonesFromWorld();
|
||||||
void DeleteFromDB();
|
void DeleteFromDB();
|
||||||
|
|
||||||
uint64 const& GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
|
ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(CORPSE_FIELD_OWNER); }
|
||||||
|
|
||||||
time_t const& GetGhostTime() const { return m_time; }
|
time_t const& GetGhostTime() const { return m_time; }
|
||||||
void ResetGhostTime() { m_time = time(NULL); }
|
void ResetGhostTime() { m_time = time(NULL); }
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ bool CannibalizeObjectCheck::operator()(Corpse* u)
|
||||||
if(u->GetType()==CORPSE_BONES)
|
if(u->GetType()==CORPSE_BONES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGUID());
|
Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGuid());
|
||||||
|
|
||||||
if( !owner || i_fobj->IsFriendlyTo(owner))
|
if( !owner || i_fobj->IsFriendlyTo(owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,9 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
|
||||||
{
|
{
|
||||||
Guard guard(i_corpseGuard);
|
Guard guard(i_corpseGuard);
|
||||||
|
|
||||||
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid.GetRawValue());
|
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
|
||||||
if( iter == i_player2corpse.end() ) return NULL;
|
if (iter == i_player2corpse.end())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES);
|
MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES);
|
||||||
|
|
||||||
|
|
@ -138,7 +139,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
|
||||||
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
||||||
|
|
||||||
Guard guard(i_corpseGuard);
|
Guard guard(i_corpseGuard);
|
||||||
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGUID());
|
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid());
|
||||||
if( iter == i_player2corpse.end() )
|
if( iter == i_player2corpse.end() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -146,7 +147,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
|
||||||
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
|
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
|
||||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||||
|
|
||||||
sObjectMgr.DeleteCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()));
|
sObjectMgr.DeleteCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGuid().GetCounter());
|
||||||
corpse->RemoveFromWorld();
|
corpse->RemoveFromWorld();
|
||||||
|
|
||||||
i_player2corpse.erase(iter);
|
i_player2corpse.erase(iter);
|
||||||
|
|
@ -158,14 +159,14 @@ ObjectAccessor::AddCorpse(Corpse *corpse)
|
||||||
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
||||||
|
|
||||||
Guard guard(i_corpseGuard);
|
Guard guard(i_corpseGuard);
|
||||||
MANGOS_ASSERT(i_player2corpse.find(corpse->GetOwnerGUID()) == i_player2corpse.end());
|
MANGOS_ASSERT(i_player2corpse.find(corpse->GetOwnerGuid()) == i_player2corpse.end());
|
||||||
i_player2corpse[corpse->GetOwnerGUID()] = corpse;
|
i_player2corpse[corpse->GetOwnerGuid()] = corpse;
|
||||||
|
|
||||||
// build mapid*cellid -> guid_set map
|
// build mapid*cellid -> guid_set map
|
||||||
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
|
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
|
||||||
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
|
||||||
|
|
||||||
sObjectMgr.AddCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()), corpse->GetInstanceId());
|
sObjectMgr.AddCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGuid().GetCounter(), corpse->GetInstanceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -238,7 +239,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
|
||||||
bones->SetPhaseMask(corpse->GetPhaseMask(), false);
|
bones->SetPhaseMask(corpse->GetPhaseMask(), false);
|
||||||
|
|
||||||
bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
|
bones->SetUInt32Value(CORPSE_FIELD_FLAGS, CORPSE_FLAG_UNK2 | CORPSE_FLAG_BONES);
|
||||||
bones->SetUInt64Value(CORPSE_FIELD_OWNER, 0);
|
bones->SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid());
|
||||||
|
|
||||||
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
||||||
ObjectAccessor& operator=(const ObjectAccessor &);
|
ObjectAccessor& operator=(const ObjectAccessor &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef UNORDERED_MAP<uint64, Corpse* > Player2CorpsesMapType;
|
typedef UNORDERED_MAP<ObjectGuid, Corpse*> Player2CorpsesMapType;
|
||||||
|
|
||||||
// global (obj used for map only location local guid objects (pets currently)
|
// global (obj used for map only location local guid objects (pets currently)
|
||||||
static Unit* GetUnitInWorld(WorldObject const& obj, ObjectGuid guid);
|
static Unit* GetUnitInWorld(WorldObject const& obj, ObjectGuid guid);
|
||||||
|
|
|
||||||
|
|
@ -2449,7 +2449,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
break;
|
break;
|
||||||
case TYPEID_CORPSE:
|
case TYPEID_CORPSE:
|
||||||
m_targets.setCorpseTarget((Corpse*)result);
|
m_targets.setCorpseTarget((Corpse*)result);
|
||||||
if (Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGUID()))
|
if (Player* owner = ObjectAccessor::FindPlayer(((Corpse*)result)->GetOwnerGuid()))
|
||||||
targetUnitMap.push_back(owner);
|
targetUnitMap.push_back(owner);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2504,7 +2504,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
|
Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID());
|
||||||
if(corpse)
|
if(corpse)
|
||||||
{
|
{
|
||||||
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID());
|
Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid());
|
||||||
if(owner)
|
if(owner)
|
||||||
targetUnitMap.push_back(owner);
|
targetUnitMap.push_back(owner);
|
||||||
}
|
}
|
||||||
|
|
@ -2560,7 +2560,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
else if (m_targets.getCorpseTargetGUID())
|
else if (m_targets.getCorpseTargetGUID())
|
||||||
{
|
{
|
||||||
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()))
|
if (Corpse *corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGUID()))
|
||||||
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGUID()))
|
if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid()))
|
||||||
targetUnitMap.push_back(owner);
|
targetUnitMap.push_back(owner);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -6387,7 +6387,7 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff )
|
||||||
if(!corpse)
|
if(!corpse)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(target->GetGUID() != corpse->GetOwnerGUID())
|
if(target->GetObjectGuid() != corpse->GetOwnerGuid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!corpse->IsWithinLOSInMap(m_caster))
|
if(!corpse->IsWithinLOSInMap(m_caster))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10811"
|
#define REVISION_NR "10812"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue