From ffac5bf3690e091b68534ec0edaea85a9261f445 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 18 Nov 2023 13:08:09 -0500 Subject: [PATCH] Clamp fix for new method --- src/engine/InterestManagement/Terrain.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 90677d33..817a50cd 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -56,8 +56,8 @@ public class Terrain { this.terrain_size.x = this.zone.major_radius * 2; this.terrain_size.y = this.zone.minor_radius * 2; - this.cell_count.x = this.image_size.x - 1; - this.cell_count.y = this.image_size.y - 1; + this.cell_count.x = this.image_size.x; + this.cell_count.y = this.image_size.x; // Bug in exe this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; @@ -160,12 +160,12 @@ public class Terrain { // Calculate terrain cell with offset. Bug mirrors the exe - Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.x); + Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y); // Clamp values when standing directly on pole - terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x)); - terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y)); + terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 2, terrain_cell.x)); + terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 2, terrain_cell.y)); return terrain_cell; }