diff --git a/GlobalMethods.h b/GlobalMethods.h index a958552..2119cc9 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -149,21 +149,28 @@ namespace LuaGlobalFunctions int tbl = lua_gettop(L); uint32 i = 0; - SessionMap const& sessions = eWorld->GetAllSessions(); - for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) { - if (Player* player = it->second->GetPlayer()) - { -#ifndef TRINITY - if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster())) +#ifdef TRINITY + boost::shared_lock lock(*HashMapHolder::GetLock()); #else - if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster())) + HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); #endif + const HashMapHolder::MapType& m = eObjectAccessor->GetPlayers(); + for (HashMapHolder::MapType::const_iterator it = m.begin(); it != m.end(); ++it) + { + if (Player* player = it->second) { - ++i; - Eluna::Push(L, i); - Eluna::Push(L, player); - lua_settable(L, tbl); +#ifndef TRINITY + if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->isGameMaster())) +#else + if ((team == TEAM_NEUTRAL || player->GetTeamId() == team) && (!onlyGM || player->IsGameMaster())) +#endif + { + ++i; + Eluna::Push(L, i); + Eluna::Push(L, player); + lua_settable(L, tbl); + } } } } diff --git a/GuildMethods.h b/GuildMethods.h index c9305f7..5bc5fd6 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -21,17 +21,24 @@ namespace LuaGuild int tbl = lua_gettop(L); uint32 i = 0; - SessionMap const& sessions = eWorld->GetAllSessions(); - for (SessionMap::const_iterator it = sessions.begin(); it != sessions.end(); ++it) { - if (Player* player = it->second->GetPlayer()) +#ifdef TRINITY + boost::shared_lock lock(*HashMapHolder::GetLock()); +#else + HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); +#endif + const HashMapHolder::MapType& m = eObjectAccessor->GetPlayers(); + for (HashMapHolder::MapType::const_iterator it = m.begin(); it != m.end(); ++it) { - if (player->GetSession() && (player->GetGuildId() == guild->GetId())) + if (Player* player = it->second) { - ++i; - Eluna::Push(L, i); - Eluna::Push(L, player); - lua_settable(L, tbl); + if (player->GetSession() && (player->GetGuildId() == guild->GetId())) + { + ++i; + Eluna::Push(L, i); + Eluna::Push(L, player); + lua_settable(L, tbl); + } } } } diff --git a/MapMethods.h b/MapMethods.h index d9d1279..b1d27e0 100644 --- a/MapMethods.h +++ b/MapMethods.h @@ -259,7 +259,7 @@ namespace LuaMap uint32 weatherType = Eluna::CHECKVAL(L, 3); float grade = Eluna::CHECKVAL(L, 4); -#if ((defined(MANGOS) || defined(CMANGOS)) && defined(WOTLK)) +#if ((defined(CMANGOS) || defined(MANGOS)) && defined(WOTLK)) if (Weather::IsValidWeatherType(weatherType)) map->SetWeather(zoneId, (WeatherType)weatherType, grade, false); #else