Used by the resolver to get values for feature 0F deterministic spritegroups. */ virtual */
| 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 |
| 263 | { |
| 264 | /* We get the town from the object, or we calculate the closest |
| 265 | * town if we need to when there's no object. */ |
| 266 | const Town *t = nullptr; |
| 267 | |
| 268 | if (this->obj == nullptr) { |
| 269 | switch (variable) { |
| 270 | /* Allow these when there's no object. */ |
| 271 | case 0x41: |
| 272 | case 0x60: |
| 273 | case 0x61: |
| 274 | case 0x62: |
| 275 | case 0x64: |
| 276 | break; |
| 277 | |
| 278 | /* Allow these, but find the closest town. */ |
| 279 | case 0x45: |
| 280 | case 0x46: |
| 281 | if (!IsValidTile(this->tile)) goto unhandled; |
| 282 | t = ClosestTownFromTile(this->tile, UINT_MAX); |
| 283 | break; |
| 284 | |
| 285 | /* Construction date */ |
| 286 | case 0x42: return TimerGameCalendar::date.base(); |
| 287 | |
| 288 | /* Object founder information */ |
| 289 | case 0x44: return _current_company.base(); |
| 290 | |
| 291 | /* Object view */ |
| 292 | case 0x48: return this->view; |
| 293 | |
| 294 | case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->spec->badges, parameter); |
| 295 | |
| 296 | /* |
| 297 | * Disallow the rest: |
| 298 | * 0x40: Relative position is passed as parameter during construction. |
| 299 | * 0x43: Animation counter is only for actual tiles. |
| 300 | * 0x47: Object colour is only valid when its built. |
| 301 | * 0x63: Animation counter of nearby tile, see above. |
| 302 | */ |
| 303 | default: |
| 304 | goto unhandled; |
| 305 | } |
| 306 | |
| 307 | /* If there's an invalid tile, then we don't have enough information at all. */ |
| 308 | if (!IsValidTile(this->tile)) goto unhandled; |
| 309 | } else { |
| 310 | t = this->obj->town; |
| 311 | } |
| 312 | |
| 313 | switch (variable) { |
| 314 | /* Relative position. */ |
| 315 | case 0x40: { |
| 316 | TileIndex offset = this->tile - this->obj->location.tile; |
| 317 | uint offset_x = TileX(offset); |
| 318 | uint offset_y = TileY(offset); |
| 319 | return offset_y << 20 | offset_x << 16 | offset_y << 8 | offset_x; |
nothing calls this directly
no test coverage detected