mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 13:30:06 +00:00
Use the chunk's visibility lists when respawning mobs.
This commit is contained in:
parent
4cc1cf4f7e
commit
d6357197d3
@ -158,15 +158,14 @@ void MobManager::deadStep(Mob *mob, time_t currTime) {
|
|||||||
|
|
||||||
pkt.NPCAppearanceData = mob->appearanceData;
|
pkt.NPCAppearanceData = mob->appearanceData;
|
||||||
|
|
||||||
// FIXME: use the chunk's visibility list, when that becomes a thing
|
auto chunk = ChunkManager::grabChunk(mob->appearanceData.iX, mob->appearanceData.iY);
|
||||||
for (auto& pair : PlayerManager::players) {
|
auto chunks = ChunkManager::grabChunks(chunk);
|
||||||
Player *plr = pair.second.plr;
|
|
||||||
|
|
||||||
int diffX = abs(plr->x - mob->appearanceData.iX);
|
// notify all nearby players
|
||||||
int diffY = abs(plr->y - mob->appearanceData.iY);
|
for (Chunk *chunk : chunks) {
|
||||||
|
for (CNSocket *s : chunk->players) {
|
||||||
if (diffX < settings::PLAYERDISTANCE && diffY < settings::PLAYERDISTANCE)
|
s->sendPacket(&pkt, P_FE2CL_NPC_NEW, sizeof(sP_FE2CL_NPC_NEW));
|
||||||
pair.first->sendPacket(&pkt, P_FE2CL_NPC_NEW, sizeof(sP_FE2CL_NPC_NEW));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user