ship_cmd.c
changeset 1020 59ee8ceac74c
parent 926 a6d140a6a4de
child 1024 5e446b5b3ec5
equal deleted inserted replaced
1019:6bae6c11e865 1020:59ee8ceac74c
    19 static byte GetTileShipTrackStatus(uint tile) {
    19 static byte GetTileShipTrackStatus(uint tile) {
    20 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
    20 	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
    21 	return r | r >> 8;
    21 	return r | r >> 8;
    22 }
    22 }
    23 
    23 
       
    24 void InvalidateShipWindows(const Vehicle *v)
       
    25 {
       
    26 	const Order *o;
       
    27 
       
    28 	InvalidateWindow(WC_SHIPS_LIST, v->owner);
       
    29 
       
    30 	for ( o = v->schedule_ptr; o->type != OT_NOTHING; o++) {
       
    31 		if (o->type == OT_GOTO_STATION ) {
       
    32 			InvalidateWindow(WC_SHIPS_LIST, o->station << 16 | v->owner);
       
    33 		}
       
    34 	}
       
    35 }
       
    36 
    24 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
    37 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
    25 {
    38 {
    26 	int spritenum = ShipVehInfo(engine)->image_index;
    39 	int spritenum = ShipVehInfo(engine)->image_index;
    27 
    40 
    28 	if (is_custom_sprite(spritenum)) {
    41 	if (is_custom_sprite(spritenum)) {
   144 
   157 
   145 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
   158 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
   146 	SubtractMoneyFromPlayerFract(v->owner, cost);
   159 	SubtractMoneyFromPlayerFract(v->owner, cost);
   147 
   160 
   148 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   161 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   149 	InvalidateWindow(WC_SHIPS_LIST, v->owner);
       
   150 }
   162 }
   151 
   163 
   152 static void HandleBrokenShip(Vehicle *v)
   164 static void HandleBrokenShip(Vehicle *v)
   153 {
   165 {
   154 	if (v->breakdown_ctr != 1) {
   166 	if (v->breakdown_ctr != 1) {
   172 	}
   184 	}
   173 
   185 
   174 	if (!(v->tick_counter & 1)) {
   186 	if (!(v->tick_counter & 1)) {
   175 		if (!--v->breakdown_delay) {
   187 		if (!--v->breakdown_delay) {
   176 			v->breakdown_ctr = 0;
   188 			v->breakdown_ctr = 0;
   177 			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
   189 			InvalidateShipWindows(v);
   178 		}
   190 		}
   179 	}
   191 	}
   180 }
   192 }
   181 
   193 
   182 static void MarkShipDirty(Vehicle *v)
   194 static void MarkShipDirty(Vehicle *v)
   251 		v->dest_tile = _depots[order.station].xy;
   263 		v->dest_tile = _depots[order.station].xy;
   252 	} else {
   264 	} else {
   253 		v->dest_tile = 0;
   265 		v->dest_tile = 0;
   254 	}
   266 	}
   255 	InvalidateVehicleOrderWidget(v);
   267 	InvalidateVehicleOrderWidget(v);
       
   268 
       
   269 	InvalidateShipWindows(v);
   256 }
   270 }
   257 
   271 
   258 static void HandleShipLoading(Vehicle *v)
   272 static void HandleShipLoading(Vehicle *v)
   259 {
   273 {
   260 	if (v->current_order.type == OT_NOTHING)
   274 	if (v->current_order.type == OT_NOTHING)
   916 		v->vehstatus ^= VS_STOPPED;
   930 		v->vehstatus ^= VS_STOPPED;
   917 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   931 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   918 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   932 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   919 	}
   933 	}
   920 
   934 
       
   935 	InvalidateShipWindows(v);
       
   936 
   921 	return 0;
   937 	return 0;
   922 }
   938 }
   923 
   939 
   924 int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   940 int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   925 {
   941 {