src/depot_gui.cpp
branchNewGRF_ports
changeset 6868 7eb395287b3d
parent 6743 cabfaa4a0295
child 6870 ca3fd1fbe311
--- a/src/depot_gui.cpp	Mon Aug 27 16:28:33 2007 +0000
+++ b/src/depot_gui.cpp	Sun Sep 02 11:58:58 2007 +0000
@@ -130,27 +130,20 @@
 
 extern int WagonLengthToPixels(int len);
 
+/**
+ * This is the Callback method after the cloning attempt of a vehicle
+ * @param success indicates completion (or not) of the operation
+ * @param tile unused
+ * @param p1 unused
+ * @param p2 unused
+ */
 void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
 {
 	if (!success) return;
-	switch(GetVehicle(p1)->type) {
-		case VEH_TRAIN:    CcCloneTrain(   true, tile, p1, p2); break;
-		case VEH_ROAD:     CcCloneRoadVeh( true, tile, p1, p2); break;
-		case VEH_SHIP:     CcCloneShip(    true, tile, p1, p2); break;
-		case VEH_AIRCRAFT: CcCloneAircraft(true, tile, p1, p2); break;
-		default: NOT_REACHED();
-	}
-}
 
-static inline void ShowVehicleViewWindow(const Vehicle *v)
-{
-	switch (v->type) {
-		case VEH_TRAIN:    ShowTrainViewWindow(v);    break;
-		case VEH_ROAD:     ShowRoadVehViewWindow(v);  break;
-		case VEH_SHIP:     ShowShipViewWindow(v);     break;
-		case VEH_AIRCRAFT: ShowAircraftViewWindow(v); break;
-		default: NOT_REACHED();
-	}
+	Vehicle *v = GetVehicle(_new_vehicle_id);
+
+	ShowVehicleViewWindow(v);
 }
 
 static void DepotSellAllConfirmationCallback(Window *w, bool confirmed)
@@ -286,7 +279,7 @@
 		/*Draw the train counter */
 		i = 0;
 		u = v;
-		do i++; while ( (u=u->next) != NULL); // Determine length of train
+		do i++; while ((u = u->Next()) != NULL); // Determine length of train
 		SetDParam(0, i);                      // Set the counter
 		DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter
 	}
@@ -363,10 +356,10 @@
 			x += skip;
 
 			/* find the vehicle in this row that was clicked */
-			while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->next;
+			while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->Next();
 
 			/* if an articulated part was selected, find its parent */
-			while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
+			while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
 
 			d->wagon = v;
 
@@ -405,7 +398,7 @@
 	if (wagon == NULL) {
 		if (head != NULL) wagon = GetLastVehicleInChain(head);
 	} else  {
-		wagon = GetPrevVehicleInChain(wagon);
+		wagon = wagon->Previous();
 		if (wagon == NULL) return;
 	}
 
@@ -482,7 +475,7 @@
 	if (v == NULL) return;
 
 	if (v->HasFront() && !v->IsPrimaryVehicle()) {
-		v = GetFirstVehicleInChain(v);
+		v = v->First();
 		/* Do nothing when clicking on a train in depot with no loc attached */
 		if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return;
 	}
@@ -902,7 +895,7 @@
 							} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
 								TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
 							} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
-								ShowTrainViewWindow(gdvp.head);
+								ShowVehicleViewWindow(gdvp.head);
 							}
 						}
 					} else if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, NULL) == MODE_DRAG_VEHICLE &&