[Core] Fix crash during gm .saveall

This commit is contained in:
xfury 2016-01-20 21:07:19 +00:00 committed by Antz
parent f8f4d90dcf
commit 03ea10a6b8
2 changed files with 11 additions and 4 deletions

View File

@ -105,10 +105,15 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
void
ObjectAccessor::SaveAllPlayers()
{
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{ itr->second->SaveToDB(); }
SessionMap const& smap = sWorld.GetAllSessions();
SessionMap::const_iterator iter;
for (iter = smap.begin(); iter != smap.end(); ++iter){
if (Player* player = iter->second->GetPlayer()){
if (player->IsInWorld()){
player->SaveToDB();
}
}
}
}
void ObjectAccessor::KickPlayer(ObjectGuid guid)

View File

@ -412,6 +412,8 @@ enum RealmZone
REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
};
typedef std::unordered_map<uint32, WorldSession*> SessionMap;
/// Storage class for commands issued for delayed execution
struct CliCommandHolder
{