src/aircraft_cmd.cpp
changeset 5972 59953719a3ff
parent 5952 5c4106e01eca
child 5996 4bcab9c286d8
--- a/src/aircraft_cmd.cpp	Sat Feb 10 08:19:39 2007 +0000
+++ b/src/aircraft_cmd.cpp	Sat Feb 10 13:37:32 2007 +0000
@@ -26,6 +26,7 @@
 #include "newgrf_text.h"
 #include "newgrf_sound.h"
 #include "date.h"
+#include "spritecache.h"
 
 // this maps the terminal to its corresponding state and block flag
 // currently set for 10 terms, 4 helipads
@@ -165,6 +166,31 @@
 	}
 }
 
+/** Get the size of the sprite of an aircraft sprite heading west (used for lists)
+ * @param engine The engine to get the sprite from
+ * @param &width The width of the sprite
+ * @param &height The height of the sprite
+ */
+void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height)
+{
+	const AircraftVehicleInfo* avi = AircraftVehInfo(engine);
+	int spritenum = avi->image_index;
+	SpriteID sprite = (6 + _aircraft_sprite[spritenum]);
+
+	if (is_custom_sprite(spritenum)) {
+		sprite = GetCustomVehicleIcon(engine, DIR_W);
+		if (sprite == 0) {
+			spritenum = orig_aircraft_vehicle_info[engine - AIRCRAFT_ENGINES_INDEX].image_index;
+			sprite = (6 + _aircraft_sprite[spritenum]);
+		}
+	}
+
+	const Sprite *spr = GetSprite(sprite);
+
+	width  = spr->width ;
+	height = spr->height;
+}
+
 static int32 EstimateAircraftCost(const AircraftVehicleInfo *avi)
 {
 	return avi->base_cost * (_price.aircraft_base >> 3) >> 5;