Scan all chunks in instance instead of in view for escort missions

This commit is contained in:
gsemaj 2021-05-06 11:41:24 -04:00 committed by Gent Semaj
parent a90ba9ea08
commit eb8ec85746
3 changed files with 5 additions and 2 deletions

View File

@ -227,7 +227,7 @@ std::set<Chunk*> Chunking::getViewableChunks(ChunkPos chunk) {
/*
* inefficient algorithm to get all chunks from a specific instance
*/
static std::vector<ChunkPos> getChunksInMap(uint64_t mapNum) {
std::vector<ChunkPos> Chunking::getChunksInMap(uint64_t mapNum) {
std::vector<ChunkPos> chnks;
for (auto it = chunks.begin(); it != chunks.end(); it++) {

View File

@ -37,6 +37,7 @@ namespace Chunking {
bool chunkExists(ChunkPos chunk);
ChunkPos chunkPosAt(int posX, int posY, uint64_t instanceID);
std::set<Chunk*> getViewableChunks(ChunkPos chunkPos);
std::vector<ChunkPos> getChunksInMap(uint64_t mapNum);
bool inPopulatedChunks(std::set<Chunk*>* chnks);
void createInstance(uint64_t);

View File

@ -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) {
}
}
}
}
}
}