mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
added getNearbyPlayers
This commit is contained in:
parent
1d792a21dd
commit
0d27412d81
@ -33,8 +33,6 @@ void NPCManager::init() {
|
|||||||
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpManager);
|
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_WARP_USE_NPC, npcWarpManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CHECKNPC
|
|
||||||
|
|
||||||
void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) {
|
void NPCManager::updatePlayerNPCS(CNSocket* sock, PlayerView& view) {
|
||||||
std::list<int32_t> yesView;
|
std::list<int32_t> yesView;
|
||||||
std::list<int32_t> noView;
|
std::list<int32_t> noView;
|
||||||
|
@ -151,6 +151,20 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
|
|||||||
NPCManager::updatePlayerNPCS(sock, players[sock]);
|
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) {
|
void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
|
||||||
if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER))
|
if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER))
|
||||||
return; // ignore the malformed packet
|
return; // ignore the malformed packet
|
||||||
|
@ -27,6 +27,7 @@ namespace PlayerManager {
|
|||||||
|
|
||||||
void updatePlayer(CNSocket* key, Player plr);
|
void updatePlayer(CNSocket* key, Player plr);
|
||||||
void updatePlayerPosition(CNSocket* sock, int X, int Y, int Z);
|
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 enterPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
void loadPlayer(CNSocket* sock, CNPacketData* data);
|
void loadPlayer(CNSocket* sock, CNPacketData* data);
|
||||||
|
Loading…
Reference in New Issue
Block a user