Skip to content

Commit

Permalink
fix cullFarChunks for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
babbaj committed Jul 18, 2023
1 parent facf908 commit 188c17c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

group = 'dev.babbaj'
version = '0.40'
version = '0.41'

java {
toolchain {
Expand Down
10 changes: 4 additions & 6 deletions src/PathfinderJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ extern "C" {
std::scoped_lock lock{ctx->cacheMutex};
const auto distSqBlocks = (maxDistanceBlocks / 16) * (maxDistanceBlocks / 16);
const auto distSq = distSqBlocks;
for (auto it = ctx->chunkCache.begin(); it != ctx->chunkCache.end(); it++) {
const auto& cpos = it->first;
if (cpos.distanceToSq({chunkX, chunkZ}) > distSq) {
it = ctx->chunkCache.erase(it);
}
}
std::erase_if(ctx->chunkCache, [=](const auto& item) {
const auto cpos = item.first;
return cpos.distanceToSq({chunkX, chunkZ}) > distSq;
});
}

EXPORT jobject JNICALL Java_dev_babbaj_pathfinder_NetherPathfinder_pathFind(JNIEnv* env, jclass, Context* ctx, jint x1, jint y1, jint z1, jint x2, jint y2, jint z2, jboolean x4Min, jint timeoutMs) {
Expand Down

0 comments on commit 188c17c

Please sign in to comment.