diff src/engine.cpp @ 11171:631c89cee615 draft

(svn r15521) -Codechange: add helper function to get the display tractive effort of a vehicle.
author rubidium <rubidium@openttd.org>
date Thu, 19 Feb 2009 09:45:44 +0000
parents df23c4e04638
children 9e451d497d94
line wrap: on
line diff
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -204,6 +204,22 @@
 	}
 }
 
+/**
+ * Returns the tractive effort for display purposes.
+ * For dual-headed train-engines this is the tractive effort of both heads
+ * @return tractive effort in display units kN
+ */
+uint Engine::GetDisplayMaxTractiveEffort() const
+{
+	/* Currently only trains have 'tractive effort' */
+	switch (this->type) {
+		case VEH_TRAIN:
+			return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, 0x1F, this->u.rail.tractive_effort)) / 256;
+
+		default: NOT_REACHED();
+	}
+}
+
 /** Sets cached values in Company::num_vehicles and Group::num_vehicles
  */
 void SetCachedEngineCounts()