Check vehicle tile hash in CheckCaches

This commit is contained in:
Jonathan G Rennison
2019-05-27 15:58:30 +01:00
parent 31ad8bdd07
commit 9b87610cd6
2 changed files with 14 additions and 0 deletions

View File

@@ -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)