namespace
| 53 | "VEHICLETYPE_RESCUE_TRANSPORT", "VEHICLETYPE_CONSTRUCTION_VEHICLE"}; |
| 54 | } // namespace |
| 55 | static void extract_equipment_layout(GameState &state, sp<VehicleType> vehicle, const UFO2P &data, |
| 56 | VehicleEquipmentLayout layout, |
| 57 | const uint8_t initial_equipment[45]) |
| 58 | { |
| 59 | if (layout.slot_count > 45) |
| 60 | { |
| 61 | LogError("Invalid equipment slot count %d", (int)layout.slot_count); |
| 62 | } |
| 63 | for (int i = 0; i < layout.slot_count; i++) |
| 64 | { |
| 65 | auto &slot = layout.slots[i]; |
| 66 | vehicle->equipment_layout_slots.emplace_back(); |
| 67 | auto &outSlot = vehicle->equipment_layout_slots.back(); |
| 68 | switch (slot.type) |
| 69 | { |
| 70 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_TYPE_ENGINE: |
| 71 | outSlot.type = EquipmentSlotType::VehicleEngine; |
| 72 | break; |
| 73 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_TYPE_WEAPON: |
| 74 | outSlot.type = EquipmentSlotType::VehicleWeapon; |
| 75 | break; |
| 76 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_TYPE_GENERAL: |
| 77 | outSlot.type = EquipmentSlotType::VehicleGeneral; |
| 78 | break; |
| 79 | default: |
| 80 | LogError("Invalid equipment slot type %d", (int)slot.type); |
| 81 | } |
| 82 | switch (slot.alignment_x) |
| 83 | { |
| 84 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_LEFT: |
| 85 | outSlot.align_x = AlignmentX::Left; |
| 86 | break; |
| 87 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_CENTRE: |
| 88 | outSlot.align_x = AlignmentX::Centre; |
| 89 | break; |
| 90 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_RIGHT: |
| 91 | outSlot.align_x = AlignmentX::Right; |
| 92 | break; |
| 93 | default: |
| 94 | LogError("Invalid equipment align_x type %d", (int)slot.alignment_x); |
| 95 | } |
| 96 | switch (slot.alignment_y) |
| 97 | { |
| 98 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_TOP: |
| 99 | outSlot.align_y = AlignmentY::Top; |
| 100 | break; |
| 101 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_CENTRE: |
| 102 | outSlot.align_y = AlignmentY::Centre; |
| 103 | break; |
| 104 | case VEHICLE_EQUIPMENT_LAYOUT_SLOT_ALIGN_BOTTOM: |
| 105 | outSlot.align_y = AlignmentY::Bottom; |
| 106 | break; |
| 107 | default: |
| 108 | LogError("Invalid equipment align_y type %d", (int)slot.alignment_x); |
| 109 | } |
| 110 | |
| 111 | outSlot.bounds = {slot.position_x, slot.position_y, slot.position_x + slot.size_x, |
| 112 | slot.position_y + slot.size_y}; |
no test coverage detected