Mercurial > hg > openttd
changeset 10493:5531e81401ee draft
(svn r14748) -Codechange: unduplicate window updating when deleting vehicles.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 26 Dec 2008 21:08:51 +0000 |
parents | 28fa021b003c |
children | 36ab263a5ce8 |
files | src/aircraft_cmd.cpp src/economy.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/train_cmd.cpp src/vehicle.cpp |
diffstat | 6 files changed, 11 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -462,11 +462,7 @@ 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.
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -385,10 +385,6 @@ 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;
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -344,12 +344,6 @@ 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 @@ 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; }
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -863,11 +863,6 @@ 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; }
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1418,7 +1418,6 @@ cost.AddCost(-rear->value); if (flags & DC_EXEC) { UnlinkWagon(rear, first); - DeleteDepotHighlightOfVehicle(rear); delete rear; } } @@ -1467,7 +1466,6 @@ 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 @@ if (flags & DC_EXEC) { first = UnlinkWagon(rear, first); - DeleteDepotHighlightOfVehicle(rear); delete rear; } } @@ -1534,7 +1531,6 @@ cost.AddCost(-v->value); if (flags & DC_EXEC) { first = UnlinkWagon(v, first); - DeleteDepotHighlightOfVehicle(v); delete v; } } @@ -3934,11 +3930,7 @@ 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 @@ } } - 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;
--- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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 @@ 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);