* Fill the grf_cache of the given vehicle. * @param v The vehicle to fill the cache for. */
| 1417 | * @param v The vehicle to fill the cache for. |
| 1418 | */ |
| 1419 | void FillNewGRFVehicleCache(const Vehicle *v) |
| 1420 | { |
| 1421 | VehicleResolverObject ro(v->engine_type, v, VehicleResolverObject::WO_NONE); |
| 1422 | |
| 1423 | /* These variables we have to check; these are the ones with a cache. */ |
| 1424 | static const int cache_entries[][2] = { |
| 1425 | { 0x40, NCVV_POSITION_CONSIST_LENGTH }, |
| 1426 | { 0x41, NCVV_POSITION_SAME_ID_LENGTH }, |
| 1427 | { 0x42, NCVV_CONSIST_CARGO_INFORMATION }, |
| 1428 | { 0x43, NCVV_COMPANY_INFORMATION }, |
| 1429 | { 0x4D, NCVV_POSITION_IN_VEHICLE }, |
| 1430 | }; |
| 1431 | static_assert(NCVV_END == lengthof(cache_entries)); |
| 1432 | |
| 1433 | /* Resolve all the variables, so their caches are set. */ |
| 1434 | for (const auto &cache_entry : cache_entries) { |
| 1435 | /* Only resolve when the cache isn't valid. */ |
| 1436 | if (HasBit(v->grf_cache.cache_valid, cache_entry[1])) continue; |
| 1437 | bool stub; |
| 1438 | ro.GetScope(VSG_SCOPE_SELF)->GetVariable(cache_entry[0], 0, stub); |
| 1439 | } |
| 1440 | |
| 1441 | /* Make sure really all bits are set. */ |
| 1442 | assert(v->grf_cache.cache_valid == (1 << NCVV_END) - 1); |
| 1443 | } |
no test coverage detected