summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2020-05-12 01:19:52 +0200
committerGitHub <noreply@github.com>2020-05-12 01:19:52 +0200
commitd15c7dbdeb14f90988caeab7fa58b44876c806e2 (patch)
tree8002b6e8003864424612b42b17e6027867076dd5 /src
parent48c61c1da16f7cfc944d14ac66a3d5ae49f3a8f9 (diff)
downloadopenttd-d15c7dbdeb14f90988caeab7fa58b44876c806e2.tar.xz
Add: stations_near and industries_near cache check (#8139)
Diffstat (limited to 'src')
-rw-r--r--src/openttd.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 9bd3bf7d0..7d9bd09a6 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -64,6 +64,7 @@
#include "viewport_func.h"
#include "viewport_sprite_sorter.h"
#include "framerate_type.h"
+#include "industry.h"
#include "linkgraph/linkgraphschedule.h"
@@ -1310,6 +1311,13 @@ static void CheckCaches()
assert(memcmp(&v->cargo, buff, sizeof(VehicleCargoList)) == 0);
}
+ /* Backup stations_near */
+ std::vector<StationList> old_town_stations_near;
+ for (Town *t : Town::Iterate()) old_town_stations_near.push_back(t->stations_near);
+
+ std::vector<StationList> old_industry_stations_near;
+ for (Industry *ind : Industry::Iterate()) old_industry_stations_near.push_back(ind->stations_near);
+
for (Station *st : Station::Iterate()) {
for (CargoID c = 0; c < NUM_CARGO; c++) {
byte buff[sizeof(StationCargoList)];
@@ -1334,6 +1342,29 @@ static void CheckCaches()
DEBUG(desync, 2, "docking tile mismatch: tile %i", (int)tile);
}
}
+
+ /* Check industries_near */
+ IndustryList industries_near = st->industries_near;
+ st->RecomputeCatchment();
+ if (st->industries_near != industries_near) {
+ DEBUG(desync, 2, "station industries near mismatch: station %i", st->index);
+ }
+ }
+
+ /* Check stations_near */
+ i = 0;
+ for (Town *t : Town::Iterate()) {
+ if (t->stations_near != old_town_stations_near[i]) {
+ DEBUG(desync, 2, "town stations near mismatch: town %i", t->index);
+ }
+ i++;
+ }
+ i = 0;
+ for (Industry *ind : Industry::Iterate()) {
+ if (ind->stations_near != old_industry_stations_near[i]) {
+ DEBUG(desync, 2, "industry stations near mismatch: industry %i", ind->index);
+ }
+ i++;
}
}