mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
Various Cleanups (game N-O)
This commit is contained in:
parent
8d0c106aa4
commit
94795f2bff
14 changed files with 1560 additions and 1519 deletions
|
|
@ -40,7 +40,7 @@ INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ACE_Thread_Mutex);
|
|||
ObjectAccessor::ObjectAccessor() {}
|
||||
ObjectAccessor::~ObjectAccessor()
|
||||
{
|
||||
for(Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr)
|
||||
for (Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr)
|
||||
{
|
||||
itr->second->RemoveFromWorld();
|
||||
delete itr->second;
|
||||
|
|
@ -48,7 +48,7 @@ ObjectAccessor::~ObjectAccessor()
|
|||
}
|
||||
|
||||
Unit*
|
||||
ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid)
|
||||
ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid)
|
||||
{
|
||||
if (!guid)
|
||||
return NULL;
|
||||
|
|
@ -64,7 +64,7 @@ ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid)
|
|||
|
||||
Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
|
||||
{
|
||||
Corpse * ret = HashMapHolder<Corpse>::Find(guid);
|
||||
Corpse* ret = HashMapHolder<Corpse>::Find(guid);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
if (ret->GetMapId() != mapid)
|
||||
|
|
@ -85,12 +85,12 @@ Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
|
|||
return plr;
|
||||
}
|
||||
|
||||
Player* ObjectAccessor::FindPlayerByName(const char *name)
|
||||
Player* ObjectAccessor::FindPlayerByName(const char* name)
|
||||
{
|
||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
if (iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 ))
|
||||
if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0))
|
||||
return iter->second;
|
||||
|
||||
return NULL;
|
||||
|
|
@ -130,13 +130,13 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
|
|||
}
|
||||
|
||||
void
|
||||
ObjectAccessor::RemoveCorpse(Corpse *corpse)
|
||||
ObjectAccessor::RemoveCorpse(Corpse* corpse)
|
||||
{
|
||||
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
||||
|
||||
Guard guard(i_corpseGuard);
|
||||
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid());
|
||||
if( iter == i_player2corpse.end() )
|
||||
if (iter == i_player2corpse.end())
|
||||
return;
|
||||
|
||||
// build mapid*cellid -> guid_set map
|
||||
|
|
@ -150,7 +150,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
|
|||
}
|
||||
|
||||
void
|
||||
ObjectAccessor::AddCorpse(Corpse *corpse)
|
||||
ObjectAccessor::AddCorpse(Corpse* corpse)
|
||||
{
|
||||
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
|
||||
|
||||
|
|
@ -169,29 +169,29 @@ void
|
|||
ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map)
|
||||
{
|
||||
Guard guard(i_corpseGuard);
|
||||
for(Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
|
||||
if(iter->second->GetGrid() == gridpair)
|
||||
{
|
||||
// verify, if the corpse in our instance (add only corpses which are)
|
||||
if (map->Instanceable())
|
||||
for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
|
||||
if (iter->second->GetGrid() == gridpair)
|
||||
{
|
||||
if (iter->second->GetInstanceId() == map->GetInstanceId())
|
||||
// verify, if the corpse in our instance (add only corpses which are)
|
||||
if (map->Instanceable())
|
||||
{
|
||||
if (iter->second->GetInstanceId() == map->GetInstanceId())
|
||||
{
|
||||
grid.AddWorldObject(iter->second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.AddWorldObject(iter->second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grid.AddWorldObject(iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Corpse*
|
||||
ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
|
||||
{
|
||||
Corpse *corpse = GetCorpseForPlayerGUID(player_guid);
|
||||
if(!corpse)
|
||||
Corpse* corpse = GetCorpseForPlayerGUID(player_guid);
|
||||
if (!corpse)
|
||||
{
|
||||
//in fact this function is called from several places
|
||||
//even when player doesn't have a corpse, not an error
|
||||
|
|
@ -206,19 +206,19 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
|
|||
|
||||
// remove resurrectable corpse from grid object registry (loaded state checked into call)
|
||||
// do not load the map if it's not loaded
|
||||
Map *map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
|
||||
Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
|
||||
if (map)
|
||||
map->Remove(corpse, false);
|
||||
|
||||
// remove corpse from DB
|
||||
corpse->DeleteFromDB();
|
||||
|
||||
Corpse *bones = NULL;
|
||||
Corpse* bones = NULL;
|
||||
// create the bones only if the map and the grid is loaded at the corpse's location
|
||||
// ignore bones creating option in case insignia
|
||||
if (map && (insignia ||
|
||||
(map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) &&
|
||||
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
|
||||
(map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) &&
|
||||
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
|
||||
{
|
||||
// Create bones, don't change Corpse
|
||||
bones = new Corpse;
|
||||
|
|
@ -239,7 +239,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
|
|||
|
||||
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
|
||||
{
|
||||
if(corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
|
||||
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
|
||||
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
|
||||
}
|
||||
|
||||
|
|
@ -257,12 +257,12 @@ void ObjectAccessor::RemoveOldCorpses()
|
|||
{
|
||||
time_t now = time(NULL);
|
||||
Player2CorpsesMapType::iterator next;
|
||||
for(Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next)
|
||||
for (Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
|
||||
if(!itr->second->IsExpired(now))
|
||||
if (!itr->second->IsExpired(now))
|
||||
continue;
|
||||
|
||||
ConvertCorpseForPlayer(itr->first);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue