40 if (_debug_desync_level <= 1)
return;
43 std::vector<TownCache> old_town_caches;
45 old_town_caches.push_back(t->cache);
53 if (old_town_caches[i] != t->cache) {
54 Debug(desync, 2,
"warning: town cache mismatch: town {}", t->index);
60 std::vector<CompanyInfrastructure> old_infrastructure;
67 if (old_infrastructure[i] != c->infrastructure) {
68 Debug(desync, 2,
"warning: infrastructure cache mismatch: company {}", c->index);
82 std::vector<NewGRFCache> grf_cache;
83 std::vector<VehicleCache> veh_cache;
84 std::vector<GroundVehicleCache> gro_cache;
85 std::vector<TrainCache> tra_cache;
88 if (v != v->First() || v->vehstatus &
VS_CRASHED || !v->IsPrimaryVehicle())
continue;
90 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
92 grf_cache.emplace_back(u->grf_cache);
93 veh_cache.emplace_back(u->vcache);
116 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
118 if (grf_cache[length] != u->grf_cache) {
119 Debug(desync, 2,
"warning: newgrf cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
121 if (veh_cache[length] != u->vcache) {
122 Debug(desync, 2,
"warning: vehicle cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
127 Debug(desync, 2,
"warning: train ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
130 Debug(desync, 2,
"warning: train cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
135 Debug(desync, 2,
"warning: road vehicle ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
152 [[maybe_unused]]
const auto a = v->cargo.PeriodsInTransit();
153 [[maybe_unused]]
const auto b = v->cargo.TotalCount();
154 [[maybe_unused]]
const auto c = v->cargo.GetFeederShare();
155 v->cargo.InvalidateCache();
156 assert(a == v->cargo.PeriodsInTransit());
157 assert(b == v->cargo.TotalCount());
158 assert(c == v->cargo.GetFeederShare());
162 std::vector<StationList> old_town_stations_near;
163 for (
Town *t :
Town::Iterate()) old_town_stations_near.push_back(t->stations_near);
165 std::vector<StationList> old_industry_stations_near;
168 std::vector<IndustryList> old_station_industries_near;
182 std::map<TileIndex, bool> docking_tiles;
183 for (
TileIndex tile : st->docking_station) {
187 UpdateStationDockingTiles(st);
188 if (ta.
tile != st->docking_station.tile || ta.
w != st->docking_station.w || ta.
h != st->docking_station.h) {
189 Debug(desync, 2,
"warning: station docking mismatch: station {}, company {}", st->index, st->owner);
193 Debug(desync, 2,
"warning: docking tile mismatch: tile {}", tile);
203 if (st->industries_near != old_station_industries_near[i]) {
204 Debug(desync, 2,
"warning: station industries near mismatch: station {}", st->index);
212 if (t->stations_near != old_town_stations_near[i]) {
213 Debug(desync, 2,
"warning: town stations near mismatch: town {}", t->index);
219 if (ind->stations_near != old_industry_stations_near[i]) {
220 Debug(desync, 2,
"warning: industry stations near mismatch: industry {}", ind->index);
void UpdateAircraftCache(Aircraft *v, bool update_range=false)
Update cached values of an aircraft.
void RebuildTownCaches()
Rebuild all the cached variables of towns.
void AfterLoadCompanyStats()
Rebuilding of company statistics after loading a savegame.
void CheckCaches()
Check the validity of some of the caches.
uint PeriodsInTransit() const
Returns average number of cargo aging periods in transit for a cargo entity.
void InvalidateCache()
Invalidates the cached data and rebuilds it.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
Definition of stuff that is very close to a company, like the company struct itself.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
void FillNewGRFVehicleCache(const Vehicle *v)
Fill the grf_cache of the given vehicle.
Base class for roadstops.
void RoadVehUpdateCache(RoadVehicle *v, bool same_length=false)
Update the cache of a road vehicle.
A number of safeguards to prevent using unsafe methods.
Base classes/functions for stations.
Maps accessors for stations.
bool IsBayRoadStopTile(Tile t)
Is tile t a bay (non-drive through) road stop station?
Definition of base types and functions in a cross-platform compatible way.
Stores station stats for a single cargo.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Defines the internal data of a functional industry.
Represents the covered area of e.g.
uint16_t w
The width of the area.
void Add(TileIndex to_add)
Add a single tile to a tile area; enlarge if needed.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
A Stop for a Road Vehicle.
void UpdateCache()
Update the caches of this ship.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
Vehicle * Next() const
Get the next vehicle of this vehicle.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
Functions related to subsidies.
Base for the train class.
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
Base class for all vehicles.
@ VS_CRASHED
Vehicle is crashed.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
bool IsDockingTile(Tile t)
Checks whether the tile is marked as a dockling tile.