Core/Misc: Fixed some duplicate checks for player typeid in Unit::Kill and Spell::EffectSummonDeadPet. Also some random cleanup
This commit is contained in:
@@ -1642,7 +1642,7 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
bool corpseVisibility = false;
|
||||
if (distanceCheck)
|
||||
{
|
||||
if (const Player* thisPlayer = ToPlayer())
|
||||
if (Player const* thisPlayer = ToPlayer())
|
||||
{
|
||||
if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
|
||||
!(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST))
|
||||
@@ -1675,9 +1675,9 @@ bool WorldObject::canSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
if (!corpseVisibility && !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GHOST)))
|
||||
{
|
||||
// Alive players can see dead players in some cases, but other objects can't do that
|
||||
if (const Player* thisPlayer = ToPlayer())
|
||||
if (Player const* thisPlayer = ToPlayer())
|
||||
{
|
||||
if (const Player* objPlayer = obj->ToPlayer())
|
||||
if (Player const* objPlayer = obj->ToPlayer())
|
||||
{
|
||||
if (thisPlayer->GetTeam() != objPlayer->GetTeam() || !thisPlayer->IsGroupVisibleFor(objPlayer))
|
||||
return false;
|
||||
@@ -2018,7 +2018,6 @@ void WorldObject::SendMessageToSet(WorldPacket* data, bool self)
|
||||
SendMessageToSetInRange(data, GetVisibilityRange(), self);
|
||||
}
|
||||
|
||||
|
||||
void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/)
|
||||
{
|
||||
Trinity::MessageDistDeliverer notifier(this, data, dist);
|
||||
|
||||
@@ -15593,29 +15593,17 @@ void Unit::Kill(Unit* victim, bool durabilityLoss)
|
||||
}
|
||||
|
||||
// Hook for OnPVPKill Event
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
if (Player* killerPlr = ToPlayer())
|
||||
{
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Player* killer = ToPlayer();
|
||||
Player* killed = victim->ToPlayer();
|
||||
sScriptMgr->OnPVPKill(killer, killed);
|
||||
}
|
||||
else if (victim->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
Player* killer = ToPlayer();
|
||||
Creature* killed = victim->ToCreature();
|
||||
sScriptMgr->OnCreatureKill(killer, killed);
|
||||
}
|
||||
if (Player* killedPlr = victim->ToPlayer())
|
||||
sScriptMgr->OnPVPKill(killerPlr, killedPlr);
|
||||
else if (Creature* killedCre = victim->ToCreature())
|
||||
sScriptMgr->OnCreatureKill(killerPlr, killedCre);
|
||||
}
|
||||
else if (GetTypeId() == TYPEID_UNIT)
|
||||
else if (Creature* killerCre = ToCreature())
|
||||
{
|
||||
if (victim->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
Creature* killer = ToCreature();
|
||||
Player* killed = victim->ToPlayer();
|
||||
sScriptMgr->OnPlayerKilledByCreature(killer, killed);
|
||||
}
|
||||
if (Player* killed = victim->ToPlayer())
|
||||
sScriptMgr->OnPlayerKilledByCreature(killerCre, killed);
|
||||
}
|
||||
|
||||
if (victim->GetVehicle())
|
||||
|
||||
@@ -1993,6 +1993,7 @@ bool Guild::Validate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (broken_ranks)
|
||||
{
|
||||
m_ranks.clear();
|
||||
|
||||
@@ -685,8 +685,7 @@ void Map::RemoveFromMap(T *obj, bool remove)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::PlayerRelocation(Player* player, float x, float y, float z, float orientation)
|
||||
void Map::PlayerRelocation(Player* player, float x, float y, float z, float orientation)
|
||||
{
|
||||
ASSERT(player);
|
||||
|
||||
@@ -710,8 +709,7 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati
|
||||
player->UpdateObjectVisibility(false);
|
||||
}
|
||||
|
||||
void
|
||||
Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail)
|
||||
void Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail)
|
||||
{
|
||||
ASSERT(CheckGridIntegrity(creature, false));
|
||||
|
||||
@@ -1161,7 +1159,7 @@ bool GridMap::loadHeihgtData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
{
|
||||
map_liquidHeader header;
|
||||
fseek(in, offset, SEEK_SET);
|
||||
@@ -1203,12 +1201,12 @@ uint16 GridMap::getArea(float x, float y)
|
||||
return m_area_map[lx*16 + ly];
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromFlat(float /*x*/, float /*y*/) const
|
||||
float GridMap::getHeightFromFlat(float /*x*/, float /*y*/) const
|
||||
{
|
||||
return m_gridHeight;
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromFloat(float x, float y) const
|
||||
float GridMap::getHeightFromFloat(float x, float y) const
|
||||
{
|
||||
if (!m_V8 || !m_V9)
|
||||
return m_gridHeight;
|
||||
@@ -1290,7 +1288,7 @@ float GridMap::getHeightFromFloat(float x, float y) const
|
||||
return a * x + b * y + c;
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromUint8(float x, float y) const
|
||||
float GridMap::getHeightFromUint8(float x, float y) const
|
||||
{
|
||||
if (!m_uint8_V8 || !m_uint8_V9)
|
||||
return m_gridHeight;
|
||||
@@ -1357,7 +1355,7 @@ float GridMap::getHeightFromUint8(float x, float y) const
|
||||
return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight;
|
||||
}
|
||||
|
||||
float GridMap::getHeightFromUint16(float x, float y) const
|
||||
float GridMap::getHeightFromUint16(float x, float y) const
|
||||
{
|
||||
if (!m_uint16_V8 || !m_uint16_V9)
|
||||
return m_gridHeight;
|
||||
@@ -1424,7 +1422,7 @@ float GridMap::getHeightFromUint16(float x, float y) const
|
||||
return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight;
|
||||
}
|
||||
|
||||
float GridMap::getLiquidLevel(float x, float y)
|
||||
float GridMap::getLiquidLevel(float x, float y)
|
||||
{
|
||||
if (!m_liquid_map)
|
||||
return m_liquidLevel;
|
||||
@@ -1443,7 +1441,7 @@ float GridMap::getLiquidLevel(float x, float y)
|
||||
return m_liquid_map[cx_int*m_liquid_width + cy_int];
|
||||
}
|
||||
|
||||
uint8 GridMap::getTerrainType(float x, float y)
|
||||
uint8 GridMap::getTerrainType(float x, float y)
|
||||
{
|
||||
if (!m_liquid_type)
|
||||
return 0;
|
||||
@@ -1826,7 +1824,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* Map::GetMapName() const
|
||||
char const* Map::GetMapName() const
|
||||
{
|
||||
return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
|
||||
}
|
||||
@@ -2623,20 +2621,17 @@ void BattlegroundMap::RemoveAllPlayers()
|
||||
player->TeleportTo(player->GetBattlegroundEntryPoint());
|
||||
}
|
||||
|
||||
Creature*
|
||||
Map::GetCreature(uint64 guid)
|
||||
Creature* Map::GetCreature(uint64 guid)
|
||||
{
|
||||
return ObjectAccessor::GetObjectInMap(guid, this, (Creature*)NULL);
|
||||
}
|
||||
|
||||
GameObject*
|
||||
Map::GetGameObject(uint64 guid)
|
||||
GameObject* Map::GetGameObject(uint64 guid)
|
||||
{
|
||||
return ObjectAccessor::GetObjectInMap(guid, this, (GameObject*)NULL);
|
||||
}
|
||||
|
||||
DynamicObject*
|
||||
Map::GetDynamicObject(uint64 guid)
|
||||
DynamicObject* Map::GetDynamicObject(uint64 guid)
|
||||
{
|
||||
return ObjectAccessor::GetObjectInMap(guid, this, (DynamicObject*)NULL);
|
||||
}
|
||||
|
||||
@@ -6432,14 +6432,15 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/)
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
|
||||
return;
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
Player* _player = m_caster->ToPlayer()
|
||||
|
||||
if (!_player)
|
||||
return;
|
||||
Player* _player = m_caster->ToPlayer();
|
||||
|
||||
Pet* pet = _player->GetPet();
|
||||
if (!pet)
|
||||
return;
|
||||
if (pet->isAlive())
|
||||
if (!pet || pet->isAlive())
|
||||
return;
|
||||
|
||||
if (damage < 0)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user