| 477 | } |
| 478 | |
| 479 | static void HelicopterTickHandler(Aircraft *v) |
| 480 | { |
| 481 | Aircraft *u = v->Next()->Next(); |
| 482 | |
| 483 | if (u->vehstatus.Test(VehState::Hidden)) return; |
| 484 | |
| 485 | /* if true, helicopter rotors do not rotate. This should only be the case if a helicopter is |
| 486 | * loading/unloading at a terminal or stopped */ |
| 487 | if (v->current_order.IsType(OT_LOADING) || v->vehstatus.Test(VehState::Stopped)) { |
| 488 | if (u->cur_speed != 0) { |
| 489 | u->cur_speed++; |
| 490 | if (u->cur_speed >= 0x80 && u->state == HRS_ROTOR_MOVING_3) { |
| 491 | u->cur_speed = 0; |
| 492 | } |
| 493 | } |
| 494 | } else { |
| 495 | if (u->cur_speed == 0) { |
| 496 | u->cur_speed = 0x70; |
| 497 | } |
| 498 | if (u->cur_speed >= 0x50) { |
| 499 | u->cur_speed--; |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | int tick = ++u->tick_counter; |
| 504 | int spd = u->cur_speed >> 4; |
| 505 | |
| 506 | VehicleSpriteSeq seq; |
| 507 | if (spd == 0) { |
| 508 | u->state = HRS_ROTOR_STOPPED; |
| 509 | GetRotorImage(v, EIT_ON_MAP, &seq); |
| 510 | if (u->sprite_cache.sprite_seq == seq) return; |
| 511 | } else if (tick >= spd) { |
| 512 | u->tick_counter = 0; |
| 513 | u->state++; |
| 514 | if (u->state > HRS_ROTOR_MOVING_3) u->state = HRS_ROTOR_MOVING_1; |
| 515 | GetRotorImage(v, EIT_ON_MAP, &seq); |
| 516 | } else { |
| 517 | return; |
| 518 | } |
| 519 | |
| 520 | u->sprite_cache.sprite_seq = seq; |
| 521 | |
| 522 | u->UpdatePositionAndViewport(); |
| 523 | } |
| 524 | |
| 525 | /** |
| 526 | * Set aircraft position. |
no test coverage detected