158 |
158 |
159 return false; |
159 return false; |
160 } |
160 } |
161 #endif |
161 #endif |
162 |
162 |
163 int Aircraft::GetImage(Direction direction) const |
163 SpriteID Aircraft::GetImage(Direction direction) const |
164 { |
164 { |
165 int spritenum = this->spritenum; |
165 uint8 spritenum = this->spritenum; |
166 |
166 |
167 if (is_custom_sprite(spritenum)) { |
167 if (is_custom_sprite(spritenum)) { |
168 int sprite = GetCustomVehicleSprite(this, direction); |
168 SpriteID sprite = GetCustomVehicleSprite(this, direction); |
169 |
|
170 if (sprite != 0) return sprite; |
169 if (sprite != 0) return sprite; |
|
170 |
171 spritenum = _orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index; |
171 spritenum = _orig_aircraft_vehicle_info[this->engine_type - AIRCRAFT_ENGINES_INDEX].image_index; |
172 } |
172 } |
|
173 |
173 return direction + _aircraft_sprite[spritenum]; |
174 return direction + _aircraft_sprite[spritenum]; |
174 } |
175 } |
175 |
176 |
176 SpriteID GetRotorImage(const Vehicle *v) |
177 SpriteID GetRotorImage(const Vehicle *v) |
177 { |
178 { |
178 assert(v->subtype == AIR_HELICOPTER); |
179 assert(v->subtype == AIR_HELICOPTER); |
179 |
180 |
180 const Vehicle *w = v->Next()->Next(); |
181 const Vehicle *w = v->Next()->Next(); |
181 if (is_custom_sprite(v->spritenum)) { |
182 if (is_custom_sprite(v->spritenum)) { |
182 SpriteID spritenum = GetCustomRotorSprite(v, false); |
183 SpriteID sprite = GetCustomRotorSprite(v, false); |
183 if (spritenum != 0) return spritenum; |
184 if (sprite != 0) return sprite; |
184 } |
185 } |
185 |
186 |
186 /* Return standard rotor sprites if there are no custom sprites for this helicopter */ |
187 /* Return standard rotor sprites if there are no custom sprites for this helicopter */ |
187 return SPR_ROTOR_STOPPED + w->u.air.state; |
188 return SPR_ROTOR_STOPPED + w->u.air.state; |
188 } |
189 } |
189 |
190 |
|
191 static SpriteID GetAircraftIcon(EngineID engine) |
|
192 { |
|
193 uint8 spritenum = AircraftVehInfo(engine)->image_index; |
|
194 |
|
195 if (is_custom_sprite(spritenum)) { |
|
196 SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W); |
|
197 if (sprite != 0) return sprite; |
|
198 |
|
199 spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index; |
|
200 } |
|
201 |
|
202 return 6 + _aircraft_sprite[spritenum]; |
|
203 } |
|
204 |
190 void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal) |
205 void DrawAircraftEngine(int x, int y, EngineID engine, SpriteID pal) |
191 { |
206 { |
192 const AircraftVehicleInfo* avi = AircraftVehInfo(engine); |
207 DrawSprite(GetAircraftIcon(engine), pal, x, y); |
193 int spritenum = avi->image_index; |
208 |
194 SpriteID sprite = 0; |
209 if (!(AircraftVehInfo(engine)->subtype & AIR_CTOL)) { |
195 |
|
196 if (is_custom_sprite(spritenum)) { |
|
197 sprite = GetCustomVehicleIcon(engine, DIR_W); |
|
198 if (sprite == 0) { |
|
199 spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index; |
|
200 } |
|
201 } |
|
202 if (sprite == 0) { |
|
203 sprite = 6 + _aircraft_sprite[spritenum]; |
|
204 } |
|
205 |
|
206 DrawSprite(sprite, pal, x, y); |
|
207 |
|
208 if (!(avi->subtype & AIR_CTOL)) { |
|
209 SpriteID rotor_sprite = GetCustomRotorIcon(engine); |
210 SpriteID rotor_sprite = GetCustomRotorIcon(engine); |
210 if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; |
211 if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED; |
211 DrawSprite(rotor_sprite, PAL_NONE, x, y - 5); |
212 DrawSprite(rotor_sprite, PAL_NONE, x, y - 5); |
212 } |
213 } |
213 } |
214 } |
217 * @param width The width of the sprite |
218 * @param width The width of the sprite |
218 * @param height The height of the sprite |
219 * @param height The height of the sprite |
219 */ |
220 */ |
220 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height) |
221 void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height) |
221 { |
222 { |
222 const AircraftVehicleInfo* avi = AircraftVehInfo(engine); |
223 const Sprite *spr = GetSprite(GetAircraftIcon(engine)); |
223 int spritenum = avi->image_index; |
224 |
224 SpriteID sprite = (6 + _aircraft_sprite[spritenum]); |
225 width = spr->width; |
225 |
|
226 if (is_custom_sprite(spritenum)) { |
|
227 sprite = GetCustomVehicleIcon(engine, DIR_W); |
|
228 if (sprite == 0) { |
|
229 spritenum = _orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index; |
|
230 sprite = (6 + _aircraft_sprite[spritenum]); |
|
231 } |
|
232 } |
|
233 |
|
234 const Sprite *spr = GetSprite(sprite); |
|
235 |
|
236 width = spr->width ; |
|
237 height = spr->height; |
226 height = spr->height; |
238 } |
227 } |
239 |
228 |
240 static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi) |
229 static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi) |
241 { |
230 { |