* Animate a tile for a town. * Only certain houses can be animated. * The newhouses animation supersedes regular ones. * @param tile TileIndex of the house to animate. */
| 337 | * @param tile TileIndex of the house to animate. |
| 338 | */ |
| 339 | static void AnimateTile_Town(TileIndex tile) |
| 340 | { |
| 341 | if (GetHouseType(tile) >= NEW_HOUSE_OFFSET) { |
| 342 | AnimateNewHouseTile(tile); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | if (TimerGameTick::counter & 3) return; |
| 347 | |
| 348 | /* If the house is not one with a lift anymore, then stop this animating. |
| 349 | * Not exactly sure when this happens, but probably when a house changes. |
| 350 | * Before this was just a return...so it'd leak animated tiles.. |
| 351 | * That bug seems to have been here since day 1?? */ |
| 352 | if (!HouseSpec::Get(GetHouseType(tile))->building_flags.Test(BuildingFlag::IsAnimated)) { |
| 353 | DeleteAnimatedTile(tile); |
| 354 | return; |
| 355 | } |
| 356 | |
| 357 | if (!LiftHasDestination(tile)) { |
| 358 | uint i; |
| 359 | |
| 360 | /* Building has 6 floors, number 0 .. 6, where 1 is illegal. |
| 361 | * This is due to the fact that the first floor is, in the graphics, |
| 362 | * the height of 2 'normal' floors. |
| 363 | * Furthermore, there are 6 lift positions from floor N (incl) to floor N + 1 (excl) */ |
| 364 | do { |
| 365 | i = RandomRange(7); |
| 366 | } while (i == 1 || i * 6 == GetLiftPosition(tile)); |
| 367 | |
| 368 | SetLiftDestination(tile, i); |
| 369 | } |
| 370 | |
| 371 | int pos = GetLiftPosition(tile); |
| 372 | int dest = GetLiftDestination(tile) * 6; |
| 373 | pos += (pos < dest) ? 1 : -1; |
| 374 | SetLiftPosition(tile, pos); |
| 375 | |
| 376 | if (pos == dest) { |
| 377 | HaltLift(tile); |
| 378 | DeleteAnimatedTile(tile); |
| 379 | } |
| 380 | |
| 381 | MarkTileDirtyByTile(tile); |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Determines if a town is close to a tile. |
nothing calls this directly
no test coverage detected