added getNearbyPlayers

This commit is contained in:
CPunch 2020-08-23 10:42:37 -05:00
parent 1d792a21dd
commit 0d27412d81
3 changed files with 15 additions and 2 deletions

View File

@ -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<int32_t> yesView;
std::list<int32_t> noView;

View File

@ -151,6 +151,20 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
NPCManager::updatePlayerNPCS(sock, players[sock]);
}
std::list<CNSocket*> PlayerManager::getNearbyPlayers(int x, int y, int dist) {
std::list<CNSocket*> 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

View File

@ -27,6 +27,7 @@ namespace PlayerManager {
void updatePlayer(CNSocket* key, Player plr);
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z);
std::list<CNSocket*> getNearbyPlayers(int X, int Y, int dist);
void enterPlayer(CNSocket* sock, CNPacketData* data);
void loadPlayer(CNSocket* sock, CNPacketData* data);