diff --git a/src/bitmap_type.h b/src/bitmap_type.h index 655c8f3baa..44a05354aa 100644 --- a/src/bitmap_type.h +++ b/src/bitmap_type.h @@ -103,6 +103,11 @@ public: { return this->Contains(tile) && this->data[Index(tile)]; } + + inline bool operator==(const BitmapTileArea &other) const + { + return TileArea::operator==(other) && this->data == other.data; + } }; /** Iterator to iterate over all tiles belonging to a bitmaptilearea. */ diff --git a/src/openttd.cpp b/src/openttd.cpp index 6dced32c05..6ba396f27e 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -74,6 +74,7 @@ #include "cargopacket.h" #include "tbtr_template_vehicle.h" #include "string_func_extra.h" +#include "industry.h" #include "linkgraph/linkgraphschedule.h" #include "tracerestrict.h" @@ -1308,20 +1309,63 @@ void CheckCaches(bool force_check, std::function log) /* Check the town caches. */ std::vector old_town_caches; + std::vector old_town_cargo_accepted_totals; + std::vector old_town_stations_nears; Town *t; FOR_ALL_TOWNS(t) { old_town_caches.push_back(t->cache); + old_town_cargo_accepted_totals.push_back(t->cargo_accepted_total); + old_town_stations_nears.push_back(t->stations_near); + } + + std::vector old_station_industries_nears; + std::vector old_station_catchment_tiles; + Station *st; + FOR_ALL_STATIONS(st) { + old_station_industries_nears.push_back(st->industries_near); + old_station_catchment_tiles.push_back(st->catchment_tiles); + } + + std::vector old_industry_stations_nears; + Industry *ind; + FOR_ALL_INDUSTRIES(ind) { + old_industry_stations_nears.push_back(ind->stations_near); } extern void RebuildTownCaches(); RebuildTownCaches(); RebuildSubsidisedSourceAndDestinationCache(); + Station::RecomputeCatchmentForAll(); + uint i = 0; FOR_ALL_TOWNS(t) { if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) { CCLOG("town cache mismatch: town %i", (int)t->index); } + if (old_town_cargo_accepted_totals[i] != t->cargo_accepted_total) { + CCLOG("town cargo_accepted_total mismatch: town %i", (int)t->index); + } + if (old_town_stations_nears[i] != t->stations_near) { + CCLOG("town stations_near mismatch: town %i", (int)t->index); + } + i++; + } + i = 0; + FOR_ALL_STATIONS(st) { + if (old_station_industries_nears[i] != st->industries_near) { + CCLOG("station industries_near mismatch: st %i", (int)st->index); + } + if (!(old_station_catchment_tiles[i] == st->catchment_tiles)) { + CCLOG("station stations_near mismatch: st %i", (int)st->index); + } + i++; + } + i = 0; + FOR_ALL_INDUSTRIES(ind) { + if (old_industry_stations_nears[i] != ind->stations_near) { + CCLOG("indsutry stations_near mismatch: ind %i", (int)ind->index); + } i++; } @@ -1503,7 +1547,6 @@ void CheckCaches(bool force_check, std::function log) assert(memcmp(&v->cargo, buff, sizeof(VehicleCargoList)) == 0); } - Station *st; FOR_ALL_STATIONS(st) { for (CargoID c = 0; c < NUM_CARGO; c++) { byte buff[sizeof(StationCargoList)]; diff --git a/src/tilearea_type.h b/src/tilearea_type.h index d970acf443..2bae4f7d54 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -62,6 +62,11 @@ struct OrthogonalTileArea { { return TILE_ADDXY(this->tile, this->w / 2, this->h / 2); } + + inline bool operator==(const OrthogonalTileArea &other) const + { + return std::tie(tile, w, h) == std::tie(other.tile, other.w, other.h); + } }; /** Represents a diagonal tile area. */