From 15c600d64f9548c2a1130eb161bc9d86e06b1aef Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 25 Jun 2020 17:43:25 +0100 Subject: [PATCH] Fix station and town kdtrees with maps larger than 64k --- src/station_kdtree.h | 14 +++++++------- src/town_kdtree.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/station_kdtree.h b/src/station_kdtree.h index 321bbacc6f..86882e5d67 100644 --- a/src/station_kdtree.h +++ b/src/station_kdtree.h @@ -15,8 +15,8 @@ #include "station_base.h" #include "map_func.h" -inline uint16 Kdtree_StationXYFunc(StationID stid, int dim) { return (dim == 0) ? TileX(BaseStation::Get(stid)->xy) : TileY(BaseStation::Get(stid)->xy); } -typedef Kdtree StationKdtree; +inline uint32 Kdtree_StationXYFunc(StationID stid, int dim) { return (dim == 0) ? TileX(BaseStation::Get(stid)->xy) : TileY(BaseStation::Get(stid)->xy); } +typedef Kdtree StationKdtree; extern StationKdtree _station_kdtree; /** @@ -28,11 +28,11 @@ extern StationKdtree _station_kdtree; template void ForAllStationsRadius(TileIndex center, uint radius, Func func) { - uint16 x1, y1, x2, y2; - x1 = (uint16)max(0, TileX(center) - radius); - x2 = (uint16)min(TileX(center) + radius + 1, MapSizeX()); - y1 = (uint16)max(0, TileY(center) - radius); - y2 = (uint16)min(TileY(center) + radius + 1, MapSizeY()); + uint32 x1, y1, x2, y2; + x1 = (uint32)max(0, TileX(center) - radius); + x2 = (uint32)min(TileX(center) + radius + 1, MapSizeX()); + y1 = (uint32)max(0, TileY(center) - radius); + y2 = (uint32)min(TileY(center) + radius + 1, MapSizeY()); _station_kdtree.FindContained(x1, y1, x2, y2, [&](StationID id) { func(Station::Get(id)); diff --git a/src/town_kdtree.h b/src/town_kdtree.h index 9241655854..af48227ad9 100644 --- a/src/town_kdtree.h +++ b/src/town_kdtree.h @@ -13,8 +13,8 @@ #include "core/kdtree.hpp" #include "town.h" -inline uint16 Kdtree_TownXYFunc(TownID tid, int dim) { return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy); } -typedef Kdtree TownKdtree; +inline uint32 Kdtree_TownXYFunc(TownID tid, int dim) { return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy); } +typedef Kdtree TownKdtree; extern TownKdtree _town_kdtree; extern TownKdtree _town_local_authority_kdtree;