src/vehicle.h
changeset 7492 35acee076719
parent 7490 bb27d92565d3
child 7493 07944c9e005f
--- a/src/vehicle.h	Thu Aug 30 12:10:32 2007 +0000
+++ b/src/vehicle.h	Thu Aug 30 13:03:56 2007 +0000
@@ -222,9 +222,9 @@
 	VehicleTypeByte type;    ///< Type of vehicle
 	byte subtype;            // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
 
-	Vehicle *next;           // next
+	Vehicle *next;           // pointer to the next vehicle in the chain
 	Vehicle *first;          // NOSAVE: pointer to the first vehicle in the chain
-	Vehicle *depot_list;     //NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
+	Vehicle *depot_list;     // NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
 
 	StringID string_id;      // Displayed string
 
@@ -455,7 +455,24 @@
 	 */
 	Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
 
-	bool IsValid() const { return this->type != VEH_INVALID; }
+	/**
+	 * Is this vehicle a valid vehicle?
+	 * @return true if and only if the vehicle is valid.
+	 */
+	inline bool IsValid() const { return this->type != VEH_INVALID; }
+
+	/**
+	 * Set the next vehicle of this vehicle.
+	 * @param next the next vehicle. NULL removes the next vehicle.
+	 */
+	void SetNext(Vehicle *next) { this->next = next; }
+
+	/**
+	 * Get the next vehicle of this vehicle.
+	 * @note articulated parts are also counted as vehicles.
+	 * @return the next vehicle or NULL when there isn't a next vehicle.
+	 */
+	inline Vehicle *Next() const { return this->next; }
 };
 
 /**
@@ -632,7 +649,7 @@
 Direction GetDirectionTowards(const Vehicle *v, int x, int y);
 
 #define BEGIN_ENUM_WAGONS(v) do {
-#define END_ENUM_WAGONS(v) } while ((v = v->next) != NULL);
+#define END_ENUM_WAGONS(v) } while ((v = v->Next()) != NULL);
 
 static inline VehicleID GetMaxVehicleIndex()
 {