void ObjectAccessor::SaveAllPlayers() { SKYFIRE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); HashMapHolder<Player>::MapType const& m = GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) itr->second->SaveToDB(); }
Corpse* ObjectAccessor::GetCorpseForPlayerGUID(uint64 guid) { SKYFIRE_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid); if (iter == i_player2corpse.end()) return NULL; ASSERT(iter->second->GetType() != CORPSE_BONES); return iter->second; }
Player* ObjectAccessor::FindPlayerByName(const char* name) { SKYFIRE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); std::string nameStr = name; std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower); HashMapHolder<Player>::MapType const& m = GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter) { if (!iter->second->IsInWorld()) continue; std::string currentName = iter->second->GetName(); std::transform(currentName.begin(), currentName.end(), currentName.begin(), ::tolower); if (nameStr.compare(currentName) == 0) return iter->second; } return NULL; }
static bool HandleGMListIngameCommand(ChatHandler* handler, char const* /*args*/) { bool first = true; bool footer = false; SKYFIRE_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock()); HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers(); for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { AccountTypes itrSec = itr->second->GetSession()->GetSecurity(); if ((itr->second->isGameMaster() || (!AccountMgr::IsPlayerAccount(itrSec) && itrSec <= AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && (!handler->GetSession() || itr->second->IsVisibleGloballyFor(handler->GetSession()->GetPlayer()))) { if (first) { first = false; footer = true; handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } char const* name = itr->second->GetName(); uint8 security = itrSec; uint8 max = ((16 - strlen(name)) / 2); uint8 max2 = max; if ((max + max2 + strlen(name)) == 16) max2 = max - 1; if (handler->GetSession()) handler->PSendSysMessage("| %s GMLevel %u", name, security); else handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); } } if (footer) handler->SendSysMessage("========================"); if (first) handler->SendSysMessage(LANG_GMS_NOT_LOGGED); return true; }
void ObjectAccessor::AddCorpsesToGrid(GridCoord const& gridpair, GridType& grid, Map* map) { SKYFIRE_READ_GUARD(ACE_RW_Thread_Mutex, i_corpseLock); for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) { // We need this check otherwise a corpose may be added to a grid twice if (iter->second->IsInGrid()) continue; if (iter->second->GetGridCoord() == gridpair) { // 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); } } }