43 std::vector<TownCache> old_town_caches;
45 old_town_caches.push_back(t->cache);
53 if (old_town_caches[i] != t->cache) {
60 std::vector<CompanyInfrastructure> old_infrastructure;
67 if (old_infrastructure[i] != c->infrastructure) {
81 std::vector<NewGRFCache> grf_cache;
82 std::vector<VehicleCache> veh_cache;
83 std::vector<GroundVehicleCache> gro_cache;
84 std::vector<TrainCache> tra_cache;
87 if (v != v->First() || v->vehstatus.Test(
VehState::Crashed) || !v->IsPrimaryVehicle())
continue;
89 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
91 grf_cache.emplace_back(u->grf_cache);
92 veh_cache.emplace_back(u->vcache);
115 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
117 if (grf_cache[length] != u->grf_cache) {
118 Debug(
Facility::Desync,
Severity::Warning,
"warning: newgrf cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
120 if (veh_cache[length] != u->vcache) {
121 Debug(
Facility::Desync,
Severity::Warning,
"warning: vehicle cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
134 Debug(
Facility::Desync,
Severity::Warning,
"warning: road vehicle ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
151 [[maybe_unused]]
const auto a = v->cargo.PeriodsInTransit();
152 [[maybe_unused]]
const auto b = v->cargo.TotalCount();
153 [[maybe_unused]]
const auto c = v->cargo.GetFeederShare();
154 v->cargo.InvalidateCache();
155 assert(a == v->cargo.PeriodsInTransit());
156 assert(b == v->cargo.TotalCount());
157 assert(c == v->cargo.GetFeederShare());
161 std::vector<StationList> old_town_stations_near;
162 for (
Town *t :
Town::Iterate()) old_town_stations_near.push_back(t->stations_near);
164 std::vector<StationList> old_industry_stations_near;
167 std::vector<IndustryList> old_station_industries_near;
176 [[maybe_unused]]
const auto b = cargo_list.
TotalCount();
184 std::map<TileIndex, bool> docking_tiles;
185 for (
TileIndex tile : st->docking_station) {
189 UpdateStationDockingTiles(st);
190 if (ta.
tile != st->docking_station.tile || ta.
w != st->docking_station.w || ta.
h != st->docking_station.h) {
205 if (st->industries_near != old_station_industries_near[i]) {
214 if (t->stations_near != old_town_stations_near[i]) {
221 if (ind->stations_near != old_industry_stations_near[i]) {
229 if (v != v->First() || v->vehstatus.Test(
VehState::Crashed) || !v->IsPrimaryVehicle())
continue;
232 if (v->Last()->Next() !=
nullptr) {
233 Debug(
Facility::Desync,
Severity::Warning,
"warning: vehicle cache mismatch, last vehicle must not have a next vehicle: type {}, vehicle {}, company {}, unit number {}, invalid 'Last()'", v->type, v->index, v->owner, v->unitnumber);
237 for (
Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
238 if (u->Last() != v->Last()) {
239 Debug(
Facility::Desync,
Severity::Warning,
"warning: vehicle cache mismatch, all vehicles in chain must have same last vehicle: type {}, vehicle {}, company {}, unit number {}, invalid 'Last()'", v->type, v->index, v->owner, v->unitnumber);
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.
CargoList that is used for stations.
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.
bool IsVisibleSeverity(Facility facility, Severity severity)
Test if debug severity is visible for the given facility.
#define Debug(facility, severity, format_string,...)
Output a line of debugging information.
@ Desync
Desync message facility.
@ Warning
Warning, wrong but okay if you don't know.
@ 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.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
const GoodsEntryData & GetData() const
Get optional cargo packet/flow data.
bool HasData() const
Test if this goods entry has optional cargo packet/flow data.
Defines the internal data of a functional industry.
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< Town > Iterate(size_t from=0)
A Stop for a Road Vehicle.
void UpdateCache()
Update the caches of this ship.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
static Train * From(Vehicle *v)
static void RecomputeCatchmentForAll()
Recomputes catchment of all stations.
void ConsistChanged(ConsistChangeFlags allowed_changes)
Recalculates the cached stuff of a train.
Vehicle * Next() const
Get the next vehicle of this vehicle.
void RebuildSubsidisedSourceAndDestinationCache()
Perform a full rebuild of the subsidies cache.
Functions related to subsidies.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Base for the train class.
static constexpr ConsistChangeFlags CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
Base class for all vehicles.
@ Crashed
Vehicle is crashed.
@ Aircraft
Aircraft vehicle type.
@ Train
Train vehicle type.
bool IsDockingTile(Tile t)
Checks whether the tile is marked as a dockling tile.