ship_cmd.c
changeset 1055 cc4f60cc9102
parent 1053 8d90844ddc2e
child 1093 4fdc46eaf423
equal deleted inserted replaced
1054:4dc4ed66882d 1055:cc4f60cc9102
    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 *order;
       
    27 
       
    28 	InvalidateWindow(WC_SHIPS_LIST, v->owner);
       
    29 
       
    30 	FOR_VEHICLE_ORDERS(v, order) {
       
    31 			if (order->type == OT_GOTO_STATION ) {
       
    32 			InvalidateWindow(WC_SHIPS_LIST, (order->station << 16) | v->owner);
       
    33 		}
       
    34 	}
       
    35 }
       
    36 
       
    37 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
    24 void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
    38 {
    25 {
    39 	int spritenum = ShipVehInfo(engine)->image_index;
    26 	int spritenum = ShipVehInfo(engine)->image_index;
    40 
    27 
    41 	if (is_custom_sprite(spritenum)) {
    28 	if (is_custom_sprite(spritenum)) {
   157 
   144 
   158 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
   145 	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
   159 	SubtractMoneyFromPlayerFract(v->owner, cost);
   146 	SubtractMoneyFromPlayerFract(v->owner, cost);
   160 
   147 
   161 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
   148 	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
       
   149 	//we need this for the profit
       
   150 	InvalidateWindowClasses(WC_SHIPS_LIST);
   162 }
   151 }
   163 
   152 
   164 static void HandleBrokenShip(Vehicle *v)
   153 static void HandleBrokenShip(Vehicle *v)
   165 {
   154 {
   166 	if (v->breakdown_ctr != 1) {
   155 	if (v->breakdown_ctr != 1) {
   184 	}
   173 	}
   185 
   174 
   186 	if (!(v->tick_counter & 1)) {
   175 	if (!(v->tick_counter & 1)) {
   187 		if (!--v->breakdown_delay) {
   176 		if (!--v->breakdown_delay) {
   188 			v->breakdown_ctr = 0;
   177 			v->breakdown_ctr = 0;
   189 			InvalidateShipWindows(v);
   178 			InvalidateWindowClasses(WC_SHIPS_LIST);
   190 		}
   179 		}
   191 	}
   180 	}
   192 }
   181 }
   193 
   182 
   194 static void MarkShipDirty(Vehicle *v)
   183 static void MarkShipDirty(Vehicle *v)
   266 		v->dest_tile = 0;
   255 		v->dest_tile = 0;
   267 	}
   256 	}
   268 
   257 
   269 	InvalidateVehicleOrder(v);
   258 	InvalidateVehicleOrder(v);
   270 
   259 
   271 	InvalidateShipWindows(v);
   260 	InvalidateWindowClasses(WC_SHIPS_LIST);
   272 }
   261 }
   273 
   262 
   274 static void HandleShipLoading(Vehicle *v)
   263 static void HandleShipLoading(Vehicle *v)
   275 {
   264 {
   276 	if (v->current_order.type == OT_NOTHING)
   265 	if (v->current_order.type == OT_NOTHING)
   368 	v->cur_speed = 0;
   357 	v->cur_speed = 0;
   369 	RecalcShipStuff(v);
   358 	RecalcShipStuff(v);
   370 
   359 
   371 	PlayShipSound(v);
   360 	PlayShipSound(v);
   372 	VehicleServiceInDepot(v);
   361 	VehicleServiceInDepot(v);
       
   362 	InvalidateWindowClasses(WC_SHIPS_LIST);
   373 }
   363 }
   374 
   364 
   375 static bool ShipAccelerate(Vehicle *v)
   365 static bool ShipAccelerate(Vehicle *v)
   376 {
   366 {
   377 	uint spd;
   367 	uint spd;
   441 					v->index,
   431 					v->index,
   442 					0);
   432 					0);
   443 			}
   433 			}
   444 		}
   434 		}
   445 	}
   435 	}
       
   436 	InvalidateWindowClasses(WC_SHIPS_LIST);
   446 }
   437 }
   447 
   438 
   448 static void ShipArrivesAt(Vehicle *v, Station *st)
   439 static void ShipArrivesAt(Vehicle *v, Station *st)
   449 {
   440 {
   450 	/* Check if station was ever visited before */
   441 	/* Check if station was ever visited before */
   929 		v->vehstatus ^= VS_STOPPED;
   920 		v->vehstatus ^= VS_STOPPED;
   930 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   921 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   931 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   922 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   932 	}
   923 	}
   933 
   924 
   934 	InvalidateShipWindows(v);
   925 	InvalidateWindowClasses(WC_SHIPS_LIST);
   935 
   926 
   936 	return 0;
   927 	return 0;
   937 }
   928 }
   938 
   929 
   939 int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
   930 int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)