Changeset - r22683:4194bc6d3798
[Not reviewed]
master
0 1 0
adf88 - 7 years ago 2017-08-31 06:47:17
adf88@openttd.org
(svn r27904) -Fix [FS#6593]: When last vehicle is removed from shared orders group, hide the "Stop sharing" button in vehile orders window
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -2656,49 +2656,49 @@ void Vehicle::AddToShared(Vehicle *share
 

	
 
/**
 
 * Removes the vehicle from the shared order list.
 
 */
 
void Vehicle::RemoveFromShared()
 
{
 
	/* Remember if we were first and the old window number before RemoveVehicle()
 
	 * as this changes first if needed. */
 
	bool were_first = (this->FirstShared() == this);
 
	VehicleListIdentifier vli(VL_SHARED_ORDERS, this->type, this->owner, this->FirstShared()->index);
 

	
 
	this->orders.list->RemoveVehicle(this);
 

	
 
	if (!were_first) {
 
		/* We are not the first shared one, so only relink our previous one. */
 
		this->previous_shared->next_shared = this->NextShared();
 
	}
 

	
 
	if (this->next_shared != NULL) this->next_shared->previous_shared = this->previous_shared;
 

	
 

	
 
	if (this->orders.list->GetNumVehicles() == 1) {
 
		/* When there is only one vehicle, remove the shared order list window. */
 
		DeleteWindowById(GetWindowClassForVehicleType(this->type), vli.Pack());
 
		InvalidateVehicleOrder(this->FirstShared(), 0);
 
		InvalidateVehicleOrder(this->FirstShared(), VIWD_MODIFY_ORDERS);
 
	} else if (were_first) {
 
		/* If we were the first one, update to the new first one.
 
		 * Note: FirstShared() is already the new first */
 
		InvalidateWindowData(GetWindowClassForVehicleType(this->type), vli.Pack(), this->FirstShared()->index | (1U << 31));
 
	}
 

	
 
	this->next_shared     = NULL;
 
	this->previous_shared = NULL;
 
}
 

	
 
void VehiclesYearlyLoop()
 
{
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->IsPrimaryVehicle()) {
 
			/* show warning if vehicle is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
 
			Money profit = v->GetDisplayProfitThisYear();
 
			if (v->age >= 730 && profit < 0) {
 
				if (_settings_client.gui.vehicle_income_warn && v->owner == _local_company) {
 
					SetDParam(0, v->index);
 
					SetDParam(1, profit);
 
					AddVehicleAdviceNewsItem(STR_NEWS_VEHICLE_IS_UNPROFITABLE, v->index);
 
				}
 
				AI::NewEvent(v->owner, new ScriptEventVehicleUnprofitable(v->index));
0 comments (0 inline, 0 general)