Merge pull request #256 from MangosServer/master

MaNGOS requested changes
This commit is contained in:
Rochet2
2018-01-15 15:45:24 +02:00
committed by GitHub
3 changed files with 25 additions and 11 deletions

View File

@@ -254,7 +254,7 @@ namespace LuaGameObject
#endif
if (ownerGuid)
{
Unit* owner = ObjectAccessor::GetUnit(*go, ownerGuid);
Unit* owner = eObjectAccessor()GetUnit(*go, ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
return 0;

View File

@@ -156,15 +156,23 @@ namespace LuaGlobalFunctions
int tbl = lua_gettop(L);
uint32 i = 0;
#ifdef MANGOS
eObjectAccessor()DoForAllPlayers([&](Player* player){
if(player->IsInWorld())
{
if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster()))
{
Eluna::Push(L, player);
lua_rawseti(L, tbl, ++i);
}
}
});
#else
{
#ifdef TRINITY
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
#else
#ifdef MANGOS
ACE_READ_GUARD_RETURN(HashMapHolder<Player>::LockType, g, HashMapHolder<Player>::GetLock(), 0)
#else
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
#endif
#endif
const HashMapHolder<Player>::MapType& m = eObjectAccessor()GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator it = m.begin(); it != m.end(); ++it)
@@ -185,7 +193,7 @@ namespace LuaGlobalFunctions
}
}
}
#endif
lua_settop(L, tbl); // push table to top of stack
return 1;
}

View File

@@ -25,15 +25,21 @@ namespace LuaGuild
int tbl = lua_gettop(L);
uint32 i = 0;
#ifdef MANGOS
eObjectAccessor()DoForAllPlayers([&](Player* player)
{
if (player->IsInWorld() && player->GetGuildId() == guild->GetId())
{
Eluna::Push(L, player);
lua_rawseti(L, tbl, ++i);
}
});
#else
{
#ifdef TRINITY
boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
#else
#ifdef MANGOS
ACE_READ_GUARD_RETURN(HashMapHolder<Player>::LockType, g, HashMapHolder<Player>::GetLock(), 0)
#else
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
#endif
#endif
const HashMapHolder<Player>::MapType& m = eObjectAccessor()GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator it = m.begin(); it != m.end(); ++it)
@@ -48,7 +54,7 @@ namespace LuaGuild
}
}
}
#endif
lua_settop(L, tbl); // push table to top of stack
return 1;
}