* Set aircraft position. * @param v Aircraft to position. * @param x New X position. * @param y New y position. * @param z New z position. */
| 530 | * @param z New z position. |
| 531 | */ |
| 532 | void SetAircraftPosition(Aircraft *v, int x, int y, int z) |
| 533 | { |
| 534 | v->x_pos = x; |
| 535 | v->y_pos = y; |
| 536 | v->z_pos = z; |
| 537 | |
| 538 | v->UpdatePosition(); |
| 539 | v->UpdateViewport(true, false); |
| 540 | if (v->subtype == AIR_HELICOPTER) { |
| 541 | GetRotorImage(v, EIT_ON_MAP, &v->Next()->Next()->sprite_cache.sprite_seq); |
| 542 | } |
| 543 | |
| 544 | Aircraft *u = v->Next(); |
| 545 | |
| 546 | int safe_x = Clamp(x, 0, Map::MaxX() * TILE_SIZE); |
| 547 | int safe_y = Clamp(y - 1, 0, Map::MaxY() * TILE_SIZE); |
| 548 | u->x_pos = x; |
| 549 | u->y_pos = y - ((v->z_pos - GetSlopePixelZ(safe_x, safe_y)) >> 3); |
| 550 | |
| 551 | safe_y = Clamp(u->y_pos, 0, Map::MaxY() * TILE_SIZE); |
| 552 | u->z_pos = GetSlopePixelZ(safe_x, safe_y); |
| 553 | u->sprite_cache.sprite_seq.CopyWithoutPalette(v->sprite_cache.sprite_seq); // the shadow is never coloured |
| 554 | |
| 555 | u->UpdatePositionAndViewport(); |
| 556 | |
| 557 | u = u->Next(); |
| 558 | if (u != nullptr) { |
| 559 | u->x_pos = x; |
| 560 | u->y_pos = y; |
| 561 | u->z_pos = z + ROTOR_Z_OFFSET; |
| 562 | |
| 563 | u->UpdatePositionAndViewport(); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Handle Aircraft specific tasks when an Aircraft enters a hangar |
no test coverage detected