mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Check vehicle tile hash in CheckCaches
This commit is contained in:
parent
31ad8bdd07
commit
9b87610cd6
@ -1423,6 +1423,11 @@ void CheckCaches(bool force_check, std::function<void(const char *)> log)
|
||||
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
extern bool ValidateVehicleTileHash(const Vehicle *v);
|
||||
if (!ValidateVehicleTileHash(v)) {
|
||||
CCLOG("vehicle tile hash mismatch: type %i, vehicle %i, company %i, unit number %i", (int)v->type, v->index, (int)v->owner, v->unitnumber);
|
||||
}
|
||||
|
||||
extern void FillNewGRFVehicleCache(const Vehicle *v);
|
||||
if (v != v->First() || v->vehstatus & VS_CRASHED || !v->IsPrimaryVehicle()) continue;
|
||||
|
||||
|
@ -762,6 +762,15 @@ static void UpdateVehicleTileHash(Vehicle *v, bool remove)
|
||||
v->hash_tile_current = new_hash;
|
||||
}
|
||||
|
||||
bool ValidateVehicleTileHash(const Vehicle *v)
|
||||
{
|
||||
if (v->type == VEH_TRAIN && Train::From(v)->IsVirtual()) return v->hash_tile_current == nullptr;
|
||||
|
||||
int x = GB(TileX(v->tile), HASH_RES, HASH_BITS);
|
||||
int y = GB(TileY(v->tile), HASH_RES, HASH_BITS) << HASH_BITS;
|
||||
return v->hash_tile_current == &_vehicle_tile_hash[(x + y) & TOTAL_HASH_MASK];
|
||||
}
|
||||
|
||||
static Vehicle *_vehicle_viewport_hash[1 << (GEN_HASHX_BITS + GEN_HASHY_BITS)];
|
||||
|
||||
static void UpdateVehicleViewportHash(Vehicle *v, int x, int y)
|
||||
|
Loading…
Reference in New Issue
Block a user