557 |
557 |
558 *bufp = buf; |
558 *bufp = buf; |
559 return ret; |
559 return ret; |
560 } |
560 } |
561 |
561 |
|
562 static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
|
563 { |
|
564 AircraftVehicleInfo *avi = &_aircraft_vehicle_info[engine]; |
|
565 byte *buf = *bufp; |
|
566 int i; |
|
567 bool ret = false; |
|
568 |
|
569 //printf("e %x prop %x?\n", engine, prop); |
|
570 switch (prop) { |
|
571 case 0x08: { /* Sprite ID */ |
|
572 FOR_EACH_ENGINE { |
|
573 uint8 spriteid = grf_load_byte(&buf); |
|
574 |
|
575 if (spriteid == 0xFF) |
|
576 spriteid = 0xFD; // ships have different custom id in the GRF file |
|
577 |
|
578 // This is currently not used but there's no reason |
|
579 // in not having it here for the future. |
|
580 if (spriteid == 0xFD && avi[i].image_index != 0xFD) |
|
581 _engine_original_sprites[AIRCRAFT_ENGINES_INDEX + engine + i] = avi[i].image_index; |
|
582 |
|
583 avi[i].image_index = spriteid; |
|
584 } |
|
585 } break; |
|
586 case 0x09: { /* Helicopter */ |
|
587 FOR_EACH_ENGINE { |
|
588 uint8 heli = grf_load_byte(&buf); |
|
589 |
|
590 avi[i].subtype = (heli == 0) ? 0 : 1; |
|
591 } |
|
592 } break; |
|
593 case 0x0A: { /* Large */ |
|
594 FOR_EACH_ENGINE { |
|
595 uint8 large = grf_load_byte(&buf); |
|
596 |
|
597 avi[i].subtype = (large == 1) ? 3 : 1; |
|
598 } |
|
599 } break; |
|
600 case 0x0B: { /* Cost factor */ |
|
601 FOR_EACH_ENGINE { |
|
602 uint8 cost_factor = grf_load_byte(&buf); |
|
603 |
|
604 avi[i].base_cost = cost_factor; // ?? is it base_cost? |
|
605 } |
|
606 } break; |
|
607 case 0x0C: { /* Speed */ |
|
608 FOR_EACH_ENGINE { |
|
609 uint8 speed = grf_load_byte(&buf); |
|
610 |
|
611 avi[i].max_speed = speed; // ?? units |
|
612 } |
|
613 } break; |
|
614 case 0x0D: { /* Acceleration */ |
|
615 FOR_EACH_ENGINE { |
|
616 uint8 accel = grf_load_byte(&buf); |
|
617 |
|
618 avi[i].acceleration = accel; |
|
619 } |
|
620 } break; |
|
621 case 0x0E: { /* Running cost factor */ |
|
622 FOR_EACH_ENGINE { |
|
623 uint8 runcost = grf_load_byte(&buf); |
|
624 |
|
625 avi[i].running_cost = runcost; |
|
626 } |
|
627 } break; |
|
628 case 0x0F: { /* Passenger capacity */ |
|
629 FOR_EACH_ENGINE { |
|
630 uint16 capacity = grf_load_word(&buf); |
|
631 |
|
632 avi[i].passanger_capacity = capacity; |
|
633 } |
|
634 } break; |
|
635 case 0x11: { /* Mail capacity */ |
|
636 FOR_EACH_ENGINE { |
|
637 uint8 capacity = grf_load_byte(&buf); |
|
638 |
|
639 avi[i].mail_capacity = capacity; |
|
640 } |
|
641 } break; |
|
642 case 0x12: { /* SFX */ |
|
643 FOR_EACH_ENGINE { |
|
644 uint8 sfx = grf_load_byte(&buf); |
|
645 |
|
646 avi[i].sfx = sfx; |
|
647 } |
|
648 } break; |
|
649 case 0x13: { /* Cargos available for refitting */ |
|
650 FOR_EACH_ENGINE { |
|
651 uint32 refit_mask = grf_load_dword(&buf); |
|
652 |
|
653 _engine_refit_masks[AIRCRAFT_ENGINES_INDEX + engine + i] = refit_mask; |
|
654 } |
|
655 } break; |
|
656 case 0x14: { /* Callback TODO */ |
|
657 ret = true; |
|
658 } break; |
|
659 default: |
|
660 ret = true; |
|
661 } |
|
662 |
|
663 *bufp = buf; |
|
664 return ret; |
|
665 } |
|
666 |
562 #undef shift_buf |
667 #undef shift_buf |
563 |
668 |
564 /* Action 0x00 */ |
669 /* Action 0x00 */ |
565 static void VehicleChangeInfo(byte *buf, int len) |
670 static void VehicleChangeInfo(byte *buf, int len) |
566 { |
671 { |
576 * B id ID of first vehicle/station to change, if num-info is |
681 * B id ID of first vehicle/station to change, if num-info is |
577 * greater than one, this one and the following |
682 * greater than one, this one and the following |
578 * vehicles/stations will be changed |
683 * vehicles/stations will be changed |
579 * B property what property to change, depends on the feature |
684 * B property what property to change, depends on the feature |
580 * V new-info new bytes of info (variable size; depends on properties) */ |
685 * V new-info new bytes of info (variable size; depends on properties) */ |
581 /* TODO: Only trains and ships are supported for now. */ |
686 /* TODO: Stations. */ |
582 |
687 |
583 static const VCI_Handler handler[5] = { |
688 static const VCI_Handler handler[5] = { |
584 /* GSF_TRAIN */ RailVehicleChangeInfo, |
689 /* GSF_TRAIN */ RailVehicleChangeInfo, |
585 /* GSF_ROAD */ RoadVehicleChangeInfo, |
690 /* GSF_ROAD */ RoadVehicleChangeInfo, |
586 /* GSF_SHIP */ ShipVehicleChangeInfo, |
691 /* GSF_SHIP */ ShipVehicleChangeInfo, |
587 /* GSF_AIRCRAFT */ NULL, |
692 /* GSF_AIRCRAFT */ AircraftVehicleChangeInfo, |
588 /* GSF_STATION */ NULL, |
693 /* GSF_STATION */ NULL, |
589 }; |
694 }; |
590 |
695 |
591 uint8 feature; |
696 uint8 feature; |
592 uint8 numprops; |
697 uint8 numprops; |
601 engine = buf[4]; |
706 engine = buf[4]; |
602 |
707 |
603 DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", |
708 DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", |
604 feature, numprops, engine, numinfo); |
709 feature, numprops, engine, numinfo); |
605 |
710 |
606 if (feature != GSF_TRAIN && feature != GSF_ROAD && feature != GSF_SHIP) { |
711 if (feature == GSF_STATION) { |
607 grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported vehicle type %x, skipping.", feature); |
712 grfmsg(GMS_WARN, "VehicleChangeInfo: Stations unsupported, skipping."); |
608 return; |
713 return; |
609 } |
714 } |
610 |
715 |
611 ei = &_engine_info[engine + _vehshifts[feature]]; |
716 ei = &_engine_info[engine + _vehshifts[feature]]; |
612 |
717 |