Changeset - r10493:b82fe3a35854
[Not reviewed]
master
0 6 0
rubidium - 15 years ago 2008-12-26 21:08:51
rubidium@openttd.org
(svn r14748) -Codechange: unduplicate window updating when deleting vehicles.
6 files changed with 11 insertions and 39 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -462,11 +462,7 @@ CommandCost CmdBuildAircraft(TileIndex t
 

	
 
static void DoDeleteAircraft(Vehicle *v)
 
{
 
	DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
	InvalidateWindow(WC_COMPANY, v->owner);
 
	DeleteDepotHighlightOfVehicle(v);
 
	delete v;
 
	InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
 
}
 

	
 
/** Sell an aircraft.
src/economy.cpp
Show inline comments
 
@@ -385,10 +385,6 @@ void ChangeOwnershipOfCompanyItems(Owner
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
 
				if (new_owner == INVALID_OWNER) {
 
					DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
					DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
 
					DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
 

	
 
					if (v->Previous() == NULL) delete v;
 
				} else {
 
					v->owner = new_owner;
src/roadveh_cmd.cpp
Show inline comments
 
@@ -344,12 +344,6 @@ CommandCost CmdSellRoadVeh(TileIndex til
 
	CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
 

	
 
	if (flags & DC_EXEC) {
 
		// Invalidate depot
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
		DeleteDepotHighlightOfVehicle(v);
 
		delete v;
 
	}
 

	
 
@@ -537,15 +531,8 @@ static void DeleteLastRoadVeh(Vehicle *v
 
	for (; v->Next() != NULL; v = v->Next()) u = v;
 
	u->SetNext(NULL);
 

	
 
	DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 

	
 
	InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
	InvalidateWindow(WC_COMPANY, v->owner);
 

	
 
	if (IsTileType(v->tile, MP_STATION)) ClearCrashedStation(v);
 

	
 
	MarkSingleVehicleDirty(v);
 

	
 
	delete v;
 
}
 

	
src/ship_cmd.cpp
Show inline comments
 
@@ -863,11 +863,6 @@ CommandCost CmdSellShip(TileIndex tile, 
 
	CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
 

	
 
	if (flags & DC_EXEC) {
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
		DeleteDepotHighlightOfVehicle(v);
 
		delete v;
 
	}
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1418,7 +1418,6 @@ CommandCost CmdSellRailWagon(TileIndex t
 
				cost.AddCost(-rear->value);
 
				if (flags & DC_EXEC) {
 
					UnlinkWagon(rear, first);
 
					DeleteDepotHighlightOfVehicle(rear);
 
					delete rear;
 
				}
 
			}
 
@@ -1467,7 +1466,6 @@ CommandCost CmdSellRailWagon(TileIndex t
 
			cost.AddCost(-v->value);
 
			if (flags & DC_EXEC) {
 
				first = UnlinkWagon(v, first);
 
				DeleteDepotHighlightOfVehicle(v);
 
				delete v;
 

	
 
				/* 4 If the second wagon was an engine, update it to front_engine
 
@@ -1521,7 +1519,6 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
							if (flags & DC_EXEC) {
 
								first = UnlinkWagon(rear, first);
 
								DeleteDepotHighlightOfVehicle(rear);
 
								delete rear;
 
							}
 
						}
 
@@ -1534,7 +1531,6 @@ CommandCost CmdSellRailWagon(TileIndex t
 
				cost.AddCost(-v->value);
 
				if (flags & DC_EXEC) {
 
					first = UnlinkWagon(v, first);
 
					DeleteDepotHighlightOfVehicle(v);
 
					delete v;
 
				}
 
			}
 
@@ -3934,11 +3930,7 @@ static void DeleteLastWagon(Vehicle *v)
 
	for (; v->Next() != NULL; v = v->Next()) u = v;
 
	u->SetNext(NULL);
 

	
 
	if (first == v) {
 
		/* Removing front vehicle (the last to go) */
 
		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 
		InvalidateWindow(WC_COMPANY, v->owner);
 
	} else {
 
	if (first != v) {
 
		/* Recalculate cached train properties */
 
		TrainConsistChanged(first, false);
 
		/* Update the depot window if the first vehicle is in depot -
 
@@ -3948,10 +3940,6 @@ static void DeleteLastWagon(Vehicle *v)
 
		}
 
	}
 

	
 
	InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
 

	
 
	MarkSingleVehicleDirty(v);
 

	
 
	/* 'v' shouldn't be accessed after it has been deleted */
 
	TrackBits trackbits = v->u.rail.track;
 
	TileIndex tile = v->tile;
src/vehicle.cpp
Show inline comments
 
@@ -53,6 +53,7 @@
 
#include "core/alloc_func.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "vehiclelist.h"
 
#include "depot_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
@@ -668,8 +669,17 @@ void Vehicle::PreDestructor()
 
		InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile);
 
	}
 

	
 
	if (this->IsPrimaryVehicle()) {
 
		DeleteWindowById(WC_VEHICLE_VIEW, this->index);
 
		DeleteWindowById(WC_VEHICLE_DETAILS, this->index);
 
		DeleteWindowById(WC_VEHICLE_ORDERS, this->index);
 
		InvalidateWindow(WC_COMPANY, this->owner);
 
	}
 
	InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
 

	
 
	this->cargo.Truncate(0);
 
	DeleteVehicleOrders(this);
 
	DeleteDepotHighlightOfVehicle(this);
 

	
 
	extern void StopGlobalFollowVehicle(const Vehicle *v);
 
	StopGlobalFollowVehicle(this);
0 comments (0 inline, 0 general)