src/ship_cmd.cpp
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
equal deleted inserted replaced
6307:f40e88cff863 6308:646711c5feaa
   404 static bool ShipAccelerate(Vehicle *v)
   404 static bool ShipAccelerate(Vehicle *v)
   405 {
   405 {
   406 	uint spd;
   406 	uint spd;
   407 	byte t;
   407 	byte t;
   408 
   408 
   409 	spd = min(v->cur_speed + 1, v->max_speed);
   409 	spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed));
   410 
   410 
   411 	/*updates statusbar only if speed have changed to save CPU time */
   411 	/*updates statusbar only if speed have changed to save CPU time */
   412 	if (spd != v->cur_speed) {
   412 	if (spd != v->cur_speed) {
   413 		v->cur_speed = spd;
   413 		v->cur_speed = spd;
   414 		if (_patches.vehicle_speed)
   414 		if (_patches.vehicle_speed)
   549 /** returns the track to choose on the next tile, or -1 when it's better to
   549 /** returns the track to choose on the next tile, or -1 when it's better to
   550  * reverse. The tile given is the tile we are about to enter, enterdir is the
   550  * reverse. The tile given is the tile we are about to enter, enterdir is the
   551  * direction in which we are entering the tile */
   551  * direction in which we are entering the tile */
   552 static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
   552 static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
   553 {
   553 {
   554 	assert(enterdir>=0 && enterdir<=3);
   554 	assert(enterdir >= 0 && enterdir <= 3);
   555 
   555 
   556 	if (_patches.yapf.ship_use_yapf) {
   556 	if (_patches.yapf.ship_use_yapf) {
   557 		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
   557 		Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
   558 		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
   558 		return (trackdir != INVALID_TRACKDIR) ? TrackdirToTrack(trackdir) : INVALID_TRACK;
   559 	} else if (_patches.new_pathfinding_all) {
   559 	} else if (_patches.new_pathfinding_all) {
   652 		{ 0, 0, 0},
   652 		{ 0, 0, 0},
   653 		{ 0, 8, 4},
   653 		{ 0, 8, 4},
   654 	},
   654 	},
   655 	{
   655 	{
   656 		{ 0, 0, 0},
   656 		{ 0, 0, 0},
   657 		{ 8,15, 7},
   657 		{ 8, 15, 7},
   658 		{ 0, 0, 0},
   658 		{ 0, 0, 0},
   659 		{ 8,15, 6},
   659 		{ 8, 15, 6},
   660 		{ 0, 0, 0},
   660 		{ 0, 0, 0},
   661 		{ 7,15, 0},
   661 		{ 7, 15, 0},
   662 	}
   662 	}
   663 };
   663 };
   664 
   664 
   665 static void ShipController(Vehicle *v)
   665 static void ShipController(Vehicle *v)
   666 {
   666 {
   878 		v->tile = tile;
   878 		v->tile = tile;
   879 		x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
   879 		x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
   880 		y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
   880 		y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
   881 		v->x_pos = x;
   881 		v->x_pos = x;
   882 		v->y_pos = y;
   882 		v->y_pos = y;
   883 		v->z_pos = GetSlopeZ(x,y);
   883 		v->z_pos = GetSlopeZ(x, y);
   884 
   884 
   885 		v->z_height = 6;
   885 		v->z_height = 6;
   886 		v->sprite_width = 6;
   886 		v->sprite_width = 6;
   887 		v->sprite_height = 6;
   887 		v->sprite_height = 6;
   888 		v->x_offs = -3;
   888 		v->x_offs = -3;
  1063 
  1063 
  1064 	dep = FindClosestShipDepot(v);
  1064 	dep = FindClosestShipDepot(v);
  1065 	if (dep == NULL) return_cmd_error(STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT);
  1065 	if (dep == NULL) return_cmd_error(STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT);
  1066 
  1066 
  1067 	if (flags & DC_EXEC) {
  1067 	if (flags & DC_EXEC) {
       
  1068 		if (v->current_order.type == OT_LOADING) v->LeaveStation();
       
  1069 
  1068 		v->dest_tile = dep->xy;
  1070 		v->dest_tile = dep->xy;
  1069 		v->current_order.type = OT_GOTO_DEPOT;
  1071 		v->current_order.type = OT_GOTO_DEPOT;
  1070 		v->current_order.flags = OF_NON_STOP;
  1072 		v->current_order.flags = OF_NON_STOP;
  1071 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1073 		if (!(p2 & DEPOT_SERVICE)) SETBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
  1072 		v->current_order.refit_cargo = CT_INVALID;
  1074 		v->current_order.refit_cargo = CT_INVALID;