diff --git a/GameObjectMethods.h b/GameObjectMethods.h index 38d0845..d300544 100644 --- a/GameObjectMethods.h +++ b/GameObjectMethods.h @@ -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; diff --git a/GlobalMethods.h b/GlobalMethods.h index 8629b76..1106e64 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -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 lock(*HashMapHolder::GetLock()); -#else -#ifdef MANGOS - ACE_READ_GUARD_RETURN(HashMapHolder::LockType, g, HashMapHolder::GetLock(), 0) #else HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); -#endif #endif const HashMapHolder::MapType& m = eObjectAccessor()GetPlayers(); for (HashMapHolder::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; } diff --git a/GuildMethods.h b/GuildMethods.h index 0f8856f..cfc43cb 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -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 lock(*HashMapHolder::GetLock()); -#else -#ifdef MANGOS - ACE_READ_GUARD_RETURN(HashMapHolder::LockType, g, HashMapHolder::GetLock(), 0) #else HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); -#endif #endif const HashMapHolder::MapType& m = eObjectAccessor()GetPlayers(); for (HashMapHolder::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; }