From eb8ec857468f1b69036282a3c92a88a1b9760662 Mon Sep 17 00:00:00 2001 From: gsemaj Date: Thu, 6 May 2021 11:41:24 -0400 Subject: [PATCH] Scan all chunks in instance instead of in view for escort missions --- src/Chunking.cpp | 2 +- src/Chunking.hpp | 1 + src/Missions.cpp | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Chunking.cpp b/src/Chunking.cpp index 74fb873..cc620f3 100644 --- a/src/Chunking.cpp +++ b/src/Chunking.cpp @@ -227,7 +227,7 @@ std::set Chunking::getViewableChunks(ChunkPos chunk) { /* * inefficient algorithm to get all chunks from a specific instance */ -static std::vector getChunksInMap(uint64_t mapNum) { +std::vector Chunking::getChunksInMap(uint64_t mapNum) { std::vector chnks; for (auto it = chunks.begin(); it != chunks.end(); it++) { diff --git a/src/Chunking.hpp b/src/Chunking.hpp index 8efc637..3d716a8 100644 --- a/src/Chunking.hpp +++ b/src/Chunking.hpp @@ -37,6 +37,7 @@ namespace Chunking { bool chunkExists(ChunkPos chunk); ChunkPos chunkPosAt(int posX, int posY, uint64_t instanceID); std::set getViewableChunks(ChunkPos chunkPos); + std::vector getChunksInMap(uint64_t mapNum); bool inPopulatedChunks(std::set* chnks); void createInstance(uint64_t); diff --git a/src/Missions.cpp b/src/Missions.cpp index b7ca6aa..6eabf01 100644 --- a/src/Missions.cpp +++ b/src/Missions.cpp @@ -361,7 +361,8 @@ static void taskStart(CNSocket* sock, CNPacketData* data) { // if escort task, assign matching paths to all nearby NPCs if (task["m_iHTaskType"] == 6) { - for(Chunk* chunk : plr->viewableChunks) // check all NPCs in view + for (ChunkPos chunkPos : Chunking::getChunksInMap(plr->instanceID)) { // check all NPCs in the instance + Chunk* chunk = Chunking::chunks[chunkPos]; for (EntityRef ref : chunk->entities) { if (ref.type != EntityType::PLAYER) { BaseNPC* npc = (BaseNPC*)ref.getEntity(); @@ -372,6 +373,7 @@ static void taskStart(CNSocket* sock, CNPacketData* data) { } } } + } } }