File diff r13023:9f6499c8d4fb → r13024:48c81d0b078a
src/ship_cmd.cpp
Show inline comments
 
@@ -143,20 +143,20 @@ static void CheckIfShipNeedsService(Vehi
 

	
 
	const Depot *depot = FindClosestShipDepot(v);
 

	
 
	if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
 
		if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
 
	v->dest_tile = depot->xy;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
Money Ship::GetRunningCost() const
 
{
 
	return GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running;
 
}
 
@@ -178,15 +178,15 @@ void Ship::OnNewDay()
 

	
 
	this->profit_this_year -= cost.GetCost();
 
	this->running_ticks = 0;
 

	
 
	SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
	/* we need this for the profit */
 
	InvalidateWindowClasses(WC_SHIPS_LIST);
 
	SetWindowClassesDirty(WC_SHIPS_LIST);
 
}
 

	
 
Trackdir Ship::GetVehicleTrackdir() const
 
{
 
	if (this->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
 

	
 
@@ -209,14 +209,14 @@ static void HandleBrokenShip(Vehicle *v)
 
		v->breakdown_ctr = 1;
 
		v->cur_speed = 0;
 

	
 
		if (v->breakdowns_since_last_service != 255)
 
			v->breakdowns_since_last_service++;
 

	
 
		InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 

	
 
		if (!PlayVehicleSound(v, VSE_BREAKDOWN)) {
 
			SndPlayVehicleFx((_settings_game.game_creation.landscape != LT_TOYLAND) ?
 
				SND_10_TRAIN_BREAKDOWN : SND_3A_COMEDY_BREAKDOWN_2, v);
 
		}
 

	
 
@@ -226,13 +226,13 @@ static void HandleBrokenShip(Vehicle *v)
 
		}
 
	}
 

	
 
	if (!(v->tick_counter & 1)) {
 
		if (!--v->breakdown_delay) {
 
			v->breakdown_ctr = 0;
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
			SetWindowDirty(WC_VEHICLE_VIEW, v->index);
 
		}
 
	}
 
}
 

	
 
void Ship::MarkDirty()
 
{
 
@@ -287,13 +287,13 @@ void Ship::UpdateDeltaXY(Direction direc
 
	this->z_extent      = 6;
 
}
 

	
 
void RecalcShipStuff(Vehicle *v)
 
{
 
	v->UpdateViewport(false, true);
 
	InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
	SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
}
 

	
 
static const TileIndexDiffC _ship_leave_depot_offs[] = {
 
	{-1,  0},
 
	{ 0, -1}
 
};
 
@@ -321,13 +321,13 @@ static void CheckShipLeaveDepot(Ship *v)
 
	v->cur_speed = 0;
 
	RecalcShipStuff(v);
 

	
 
	PlayShipSound(v);
 
	VehicleServiceInDepot(v);
 
	InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
	InvalidateWindowClasses(WC_SHIPS_LIST);
 
	SetWindowClassesDirty(WC_SHIPS_LIST);
 
}
 

	
 
static bool ShipAccelerate(Vehicle *v)
 
{
 
	uint spd;
 
	byte t;
 
@@ -335,13 +335,13 @@ static bool ShipAccelerate(Vehicle *v)
 
	spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed));
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
 
	if (spd != v->cur_speed) {
 
		v->cur_speed = spd;
 
		if (_settings_client.gui.vehicle_speed)
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	/* Decrease somewhat when turning */
 
	if (!(v->direction & 1)) spd = spd * 3 / 4;
 

	
 
	if (spd == 0) return false;
 
@@ -624,13 +624,13 @@ static void ShipController(Ship *v)
 
				if (HasBit(r, VETS_CANNOT_ENTER)) goto reverse_direction;
 

	
 
				/* A leave station order only needs one tick to get processed, so we can
 
				 * always skip ahead. */
 
				if (v->current_order.IsType(OT_LEAVESTATION)) {
 
					v->current_order.Free();
 
					InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
					SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
				} else if (v->dest_tile != 0) {
 
					/* We have a target, let's see if we reached it... */
 
					if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
 
							DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
 
						/* We got within 3 tiles of our target buoy, so let's skip to our
 
						 * next order */
 
@@ -816,13 +816,13 @@ CommandCost CmdBuildShip(TileIndex tile,
 
		v->InvalidateNewGRFCacheOfChain();
 

	
 
		VehicleMove(v, false);
 

	
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		SetWindowDirty(WC_COMPANY, v->owner);
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
 

	
 
		Company::Get(_current_company)->num_engines[p1]++;
 
	}
 

	
 
@@ -945,14 +945,14 @@ CommandCost CmdRefitShip(TileIndex tile,
 
		v->cargo_cap = capacity;
 
		v->cargo.Truncate((v->cargo_type == new_cid) ? capacity : 0);
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 
		v->colourmap = PAL_NONE; // invalidate vehicle colour map
 
		v->InvalidateNewGRFCacheOfChain();
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
 
	}
 

	
 
	return cost;
 

	
 
}