* Implementation of var 65 * @param object ResolverObject owning the temporary storage. * @param local_id Parameter given to the callback, which is the set id, or the local id, in our terminology. * @param grfid The object's GRFID. * @param tile The tile to look from. * @param current Object for which the inquiry is made * @return The formatted answer to the callback : rr(reserved) c
| 233 | * @return The formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister) |
| 234 | */ |
| 235 | static uint32_t GetCountAndDistanceOfClosestInstance(const ResolverObject &object, uint8_t local_id, uint32_t grfid, TileIndex tile, const Object *current) |
| 236 | { |
| 237 | uint32_t grf_id = static_cast<uint32_t>(object.GetRegister(0x100)); // Get the GRFID of the definition to look for in register 100h |
| 238 | uint32_t idx; |
| 239 | |
| 240 | /* Determine what will be the object type to look for */ |
| 241 | switch (grf_id) { |
| 242 | case 0: // this is a default object type |
| 243 | idx = local_id; |
| 244 | break; |
| 245 | |
| 246 | case 0xFFFFFFFF: // current grf |
| 247 | grf_id = grfid; |
| 248 | [[fallthrough]]; |
| 249 | |
| 250 | default: // use the grfid specified in register 100h |
| 251 | idx = _object_mngr.GetID(local_id, grf_id); |
| 252 | break; |
| 253 | } |
| 254 | |
| 255 | /* If the object type is invalid, there is none and the closest is far away. */ |
| 256 | if (idx >= NUM_OBJECTS) return 0 | 0xFFFF; |
| 257 | |
| 258 | return Object::GetTypeCount(idx) << 16 | ClampTo<uint16_t>(GetClosestObject(tile, idx, current)); |
| 259 | } |
| 260 | |
| 261 | /** Used by the resolver to get values for feature 0F deterministic spritegroups. */ |
| 262 | /* virtual */ uint32_t ObjectScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const |
no test coverage detected