summaryrefslogtreecommitdiff
path: root/ship_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-05 11:28:00 +0000
committertron <tron@openttd.org>2006-06-05 11:28:00 +0000
commitcb13a1e43d20bf376f5c360fad89dca4260fb196 (patch)
treeb887bdc9f2fd2dcd8c254caa699df752e695c501 /ship_gui.c
parentb0801e4e63667a7c9a74b704c41b26ae26f52b83 (diff)
downloadopenttd-cb13a1e43d20bf376f5c360fad89dca4260fb196.tar.xz
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
Diffstat (limited to 'ship_gui.c')
-rw-r--r--ship_gui.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/ship_gui.c b/ship_gui.c
index bed2beb5d..2c156ee4d 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -4,6 +4,7 @@
#include "openttd.h"
#include "debug.h"
#include "functions.h"
+#include "ship.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "map.h"
@@ -466,11 +467,9 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
StringID str;
// Possible to refit?
- if (ShipVehInfo(v->engine_type)->refittable &&
- v->vehstatus&VS_STOPPED &&
- v->u.ship.state == 0x80 &&
- IsTileDepotType(v->tile, TRANSPORT_WATER))
+ if (ShipVehInfo(v->engine_type)->refittable && IsShipInDepotStopped(v)) {
disabled = 0;
+ }
if (v->owner != _local_player)
disabled |= 1<<8 | 1<<7;
@@ -568,7 +567,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
Vehicle *v;
uint32 h;
v = GetVehicle(w->window_number);
- h = IsTileDepotType(v->tile, TRANSPORT_WATER) && v->vehstatus & VS_HIDDEN ? (1<< 7) : (1 << 11);
+ h = IsShipInDepot(v) ? 1 << 7 : 1 << 11;
if (h != w->hidden_state) {
w->hidden_state = h;
SetWindowDirty(w);
@@ -629,7 +628,7 @@ static void DrawShipDepotWindow(Window *w)
/* determine amount of items for scroller */
num = 0;
FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile)
+ if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile)
num++;
}
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
@@ -646,7 +645,7 @@ static void DrawShipDepotWindow(Window *w)
num = w->vscroll.pos * w->hscroll.cap;
FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile &&
+ if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile &&
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
@@ -1013,7 +1012,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
DrawVehicleProfitButton(v, x, y + 13);
SetDParam(0, v->unitnumber);
- if (IsTileDepotType(v->tile, TRANSPORT_WATER) && (v->vehstatus & VS_HIDDEN))
+ if (IsShipInDepot(v))
str = STR_021F;
else
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;