diff options
author | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-02-18 21:14:52 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-03-09 20:27:11 +0100 |
commit | d84b67e54d663a62a0a90ddf3fcc7c3f728826af (patch) | |
tree | d069c9179af354b434d8e85f09f1f311673e8bac /src/station.cpp | |
parent | 7b56be0f3ac0a0257c10dc7ebe32c1fe95ea6253 (diff) | |
download | openttd-d84b67e54d663a62a0a90ddf3fcc7c3f728826af.tar.xz |
Codechange: Make a k-d tree index of stations
Diffstat (limited to 'src/station.cpp')
-rw-r--r-- | src/station.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/station.cpp b/src/station.cpp index 27063dcd7..5722fcdcf 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -21,6 +21,7 @@ #include "vehiclelist.h" #include "core/pool_func.hpp" #include "station_base.h" +#include "station_kdtree.h" #include "roadstop_base.h" #include "industry.h" #include "town.h" @@ -36,6 +37,20 @@ StationPool _station_pool("Station"); INSTANTIATE_POOL_METHODS(Station) + +StationKdtree _station_kdtree(Kdtree_StationXYFunc); + +void RebuildStationKdtree() +{ + std::vector<StationID> stids; + BaseStation *st; + FOR_ALL_STATIONS(st) { + stids.push_back(st->index); + } + _station_kdtree.Build(stids.begin(), stids.end()); +} + + BaseStation::~BaseStation() { free(this->name); @@ -146,6 +161,8 @@ Station::~Station() } CargoPacket::InvalidateAllFrom(this->index); + + _station_kdtree.Remove(this->index); } |