summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-26 20:09:25 +0000
committertruelight <truelight@openttd.org>2006-08-26 20:09:25 +0000
commit7f84bcc91733848aa829920c2cc77b4dfcacbb6d (patch)
treebe9bb22b74218db0aeaab95cdbe99ced12524a63 /vehicle.c
parenta241ec82c9203d3208701e359b253abb50483c60 (diff)
downloadopenttd-7f84bcc91733848aa829920c2cc77b4dfcacbb6d.tar.xz
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
-Codechange: DestroyVehicle is called by DeleteVehicle to remove all things where a vehicle depends on. Last 2 changes to prepare for new pool system. Not pretty now, will be soon.
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/vehicle.c b/vehicle.c
index 4800aa3de..dcd10e3e2 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -528,26 +528,21 @@ uint CountVehiclesInChain(const Vehicle* v)
return count;
}
-void DeleteVehicle(Vehicle *v)
+void DestroyVehicle(Vehicle *v)
{
- Vehicle *u;
- bool has_artic_part = false;
-
DeleteVehicleNews(v->index, INVALID_STRING_ID);
- do {
- u = v->next;
- has_artic_part = EngineHasArticPart(v);
- DeleteName(v->string_id);
- if (v->type == VEH_Road) ClearSlot(v);
- v->type = 0;
- UpdateVehiclePosHash(v, INVALID_COORD, 0);
- v->next_hash = INVALID_VEHICLE;
-
- if (v->orders != NULL)
- DeleteVehicleOrders(v);
- v = u;
- } while (v != NULL && has_artic_part);
+ DeleteName(v->string_id);
+ if (v->type == VEH_Road) ClearSlot(v);
+
+ UpdateVehiclePosHash(v, INVALID_COORD, 0);
+ v->next_hash = INVALID_VEHICLE;
+ if (v->orders != NULL) DeleteVehicleOrders(v);
+
+ /* Now remove any artic part. This will trigger an other
+ * destroy vehicle, which on his turn can remove any
+ * other artic parts. */
+ if (EngineHasArticPart(v)) DeleteVehicle(v->next);
}
void DeleteVehicleChain(Vehicle *v)