diff --git a/src/NPCManager.cpp b/src/NPCManager.cpp index d40f93d..4504391 100644 --- a/src/NPCManager.cpp +++ b/src/NPCManager.cpp @@ -33,8 +33,6 @@ void NPCManager::init() { REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpManager); } -#undef CHECKNPC - void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) { std::list yesView; std::list noView; diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index d3835b6..ab17c51 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -151,6 +151,20 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) { NPCManager::updatePlayerNPCS(sock, players[sock]); } +std::list PlayerManager::getNearbyPlayers(int x, int y, int dist) { + std::list plrs; + + for (auto pair : players) { + int diffX = abs(pair.second.plr.x - x); + int diffY = abs(pair.second.plr.x - x); + + if (diffX < dist && diffY < dist) + plrs.push_back(pair.first); + } + + return plrs; +} + void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) { if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER)) return; // ignore the malformed packet diff --git a/src/PlayerManager.hpp b/src/PlayerManager.hpp index 34cfb6a..10fac5b 100644 --- a/src/PlayerManager.hpp +++ b/src/PlayerManager.hpp @@ -27,6 +27,7 @@ namespace PlayerManager { void updatePlayer(CNSocket* key, Player plr); void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z); + std::list getNearbyPlayers(int X, int Y, int dist); void enterPlayer(CNSocket* sock, CNPacketData* data); void loadPlayer(CNSocket* sock, CNPacketData* data);