Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int GetPlayersInRange(lua_State* L)
- {
- WorldObject* obj = sEluna->CHECK_WORLDOBJECT(L, 1);
- float range = luaL_optnumber(L, 2, SIZE_OF_GRIDS);
- if (!obj)
- return 0;
- std::list<Player*> list;
- Trinity::AnyPlayerInObjectRangeCheck checker(obj, range);
- Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(obj, list, checker);
- obj->VisitNearbyGridObject(range, searcher);
- Trinity::ObjectGUIDCheck guidCheck(obj->GetGUID());
- list.remove_if(guidCheck);
- lua_newtable(L);
- int tbl = lua_gettop(L);
- uint32 i = 0;
- for (std::list<Player*>::const_iterator it = list.begin(); it != list.end(); ++it)
- {
- sEluna->PushUnsigned(L, ++i);
- sEluna->PushUnit(L, *it);
- lua_settable(L, tbl);
- }
- lua_settop(L, tbl);
- return 1;
- }
- // works
- static int GetPlayersInRange(lua_State* L)
- {
- WorldObject* obj = sEluna->CHECK_WORLDOBJECT(L, 1);
- float range = luaL_optnumber(L, 2, SIZE_OF_GRIDS);
- if (!obj)
- return 0;
- std::list<Player*> playerList;
- Trinity::AnyPlayerInObjectRangeCheck checker(obj, range);
- Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(obj, playerList, checker);
- obj->VisitNearbyWorldObject(range, searcher);
- Trinity::ObjectGUIDCheck guidCheck(obj->GetGUID());
- playerList.remove_if(guidCheck);
- lua_newtable(L);
- int tbl = lua_gettop(L);
- uint32 i = 0;
- for(std::list<Player*>::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr)
- {
- ++i;
- sEluna->PushUnsigned(L, i);
- sEluna->PushUnit(L, (*itr));
- lua_settable(L, tbl);
- }
- lua_settop(L, tbl);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement