diff options
author | peter1138 <peter1138@openttd.org> | 2006-02-20 21:49:31 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-02-20 21:49:31 +0000 |
commit | 97559a9df9e1255f6d7caa2c1851f35c10f28841 (patch) | |
tree | 8091f201e38eb46e57db61694b780a1cfa1b956b | |
parent | d77d704d27e2d86be77c39d687bd1af17dbe05f2 (diff) | |
download | openttd-97559a9df9e1255f6d7caa2c1851f35c10f28841.tar.xz |
(svn r3631) - 2cc: Remove use of some temporary variables and perform minor optimization in the form of the ternary operator.
-rw-r--r-- | aircraft_gui.c | 6 | ||||
-rw-r--r-- | roadveh_gui.c | 6 | ||||
-rw-r--r-- | ship_gui.c | 4 | ||||
-rw-r--r-- | train_gui.c | 7 |
4 files changed, 7 insertions, 16 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index b947854e5..3a78c2134 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -64,10 +64,8 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection) { - int image = GetAircraftImage(v, 6); - uint32 ormod = GetVehiclePalette(v); - if (v->vehstatus & VS_CRASHED) ormod = PALETTE_CRASH; - DrawSprite(image | ormod, x + 25, y + 10); + PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); + DrawSprite(GetAircraftImage(v, 6) | pal, x + 25, y + 10); if (v->subtype == 0) DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5); if (v->index == selection) { DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY); diff --git a/roadveh_gui.c b/roadveh_gui.c index 2c90b38ae..2d8a1826c 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -64,10 +64,8 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection) { - int image = GetRoadVehImage(v, 6); - uint32 ormod = GetVehiclePalette(v); - if (v->vehstatus & VS_CRASHED) ormod = PALETTE_CRASH; - DrawSprite(image | ormod, x + 14, y + 6); + PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); + DrawSprite(GetRoadVehImage(v, 6) | pal, x + 14, y + 6); if (v->index == selection) { DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY); diff --git a/ship_gui.c b/ship_gui.c index 394438c20..b46dfa62d 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -65,9 +65,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number) static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) { - int image = GetShipImage(v, 6); - uint32 ormod = GetVehiclePalette(v); - DrawSprite(image | ormod, x + 32, y + 10); + DrawSprite(GetShipImage(v, 6) | GetVehiclePalette(v), x + 32, y + 10); if (v->index == selection) { DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY); diff --git a/train_gui.c b/train_gui.c index 4540ce902..e7f1ace5b 100644 --- a/train_gui.c +++ b/train_gui.c @@ -358,14 +358,11 @@ static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, do { if (--skip < 0) { - int image = GetTrainImage(v, 6); - uint32 ormod = GetVehiclePalette(v); int width = v->u.rail.cached_veh_length; if (dx + width <= count) { - if (v->vehstatus & VS_CRASHED) - ormod = PALETTE_CRASH; - DrawSprite(image | ormod, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); + PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); + DrawSprite(GetTrainImage(v, 6) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); if (v->index == selection) DrawFrameRect(x - 1 + WagonLengthToPixels(dx), y - 1, x + WagonLengthToPixels(dx + width) - 1, y + 12, 15, FR_BORDERONLY); } |