From d15c7dbdeb14f90988caeab7fa58b44876c806e2 Mon Sep 17 00:00:00 2001 From: glx22 Date: Tue, 12 May 2020 01:19:52 +0200 Subject: Add: stations_near and industries_near cache check (#8139) --- src/openttd.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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 old_town_stations_near; + for (Town *t : Town::Iterate()) old_town_stations_near.push_back(t->stations_near); + + std::vector 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++; } } -- cgit v1.2.3-54-g00ecf