| 122 | } |
| 123 | |
| 124 | void InitialGameStateExtractor::extractVehicles(GameState &state) const |
| 125 | { |
| 126 | auto &data = this->ufo2p; |
| 127 | LogInfo("Number of vehicle strings: %zu", data.vehicle_names->readStrings.size()); |
| 128 | |
| 129 | for (unsigned i = 0; i < data.vehicle_data->count(); i++) |
| 130 | { |
| 131 | auto v = data.vehicle_data->get(i); |
| 132 | |
| 133 | UString id = data.getVehicleId(i); |
| 134 | |
| 135 | state.vehicle_types[id] = std::make_shared<VehicleType>(); |
| 136 | auto &vehicle = state.vehicle_types[id]; |
| 137 | auto name = data.vehicle_names->get(i); |
| 138 | vehicle->name = name; |
| 139 | vehicle->manufacturer = {&state, data.getOrgId(v.manufacturer)}; |
| 140 | // We draw objects based on centre, therefore we must adjust here |
| 141 | vehicle->image_offset = {v.image_position_1, v.image_position_2 * 3.0f / 4.0f}; |
| 142 | |
| 143 | auto ped = |
| 144 | format("%s%s", UfopaediaEntry::getPrefix(), canon_string(data.vehicle_names->get(i))); |
| 145 | vehicle->ufopaedia_entry = {&state, ped}; |
| 146 | |
| 147 | if (i < 10) |
| 148 | { |
| 149 | vehicle->researchUnlock.emplace_back(&state, |
| 150 | "RESEARCH_UNLOCK_ALIEN_CRAFT_CONTROL_SYSTEMS"); |
| 151 | vehicle->researchUnlock.emplace_back(&state, |
| 152 | "RESEARCH_UNLOCK_ALIEN_CRAFT_ENERGY_SOURCE"); |
| 153 | vehicle->researchUnlock.emplace_back(&state, "RESEARCH_UNLOCK_ALIEN_CRAFT_PROPULSION"); |
| 154 | vehicle->researchUnlock.emplace_back(&state, |
| 155 | format("RESEARCH_UNLOCK_UFO_TYPE_%d", i + 1)); |
| 156 | } |
| 157 | |
| 158 | if (v.movement_type == 0) |
| 159 | { |
| 160 | vehicle->type = VehicleType::Type::Road; |
| 161 | int image_offset = 0; |
| 162 | std::vector<VehicleType::Direction> directions = { |
| 163 | VehicleType::Direction::N, VehicleType::Direction::NE, VehicleType::Direction::E, |
| 164 | VehicleType::Direction::SE, VehicleType::Direction::S, VehicleType::Direction::SW, |
| 165 | VehicleType::Direction::W, VehicleType::Direction::NW}; |
| 166 | auto bank = VehicleType::Banking::Flat; |
| 167 | for (auto &dir : directions) |
| 168 | { |
| 169 | auto str = format("PCK:xcom3/ufodata/vehicle.pck:xcom3/ufodata/vehicle.tab:%d", |
| 170 | (int)(v.graphic_frame + image_offset++)); |
| 171 | ; |
| 172 | vehicle->directional_sprites[bank][dir] = fw().data->loadImage(str); |
| 173 | } |
| 174 | // Ground vehicles don't have diagonal ascend/descend sprites (As roads don't seem to do |
| 175 | // that) |
| 176 | directions = {VehicleType::Direction::N, VehicleType::Direction::E, |
| 177 | VehicleType::Direction::S, VehicleType::Direction::W}; |
| 178 | std::vector<VehicleType::Banking> banking = {VehicleType::Banking::Ascending, |
| 179 | VehicleType::Banking::Descending}; |
| 180 | for (auto &bank : banking) |
| 181 | { |
no test coverage detected