changeset 17165:3c9baf898829 draft

(svn r21903) -Codechange: warn only once for a train that has invalid length, not for each its wagon with invalid length
author smatz <smatz@openttd.org>
date Sun, 23 Jan 2011 17:50:24 +0000
parents bfc7b87f4672
children a8648b5d49a3
files src/train_cmd.cpp
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -104,6 +104,7 @@
 void CheckTrainsLengths()
 {
 	const Train *v;
+	bool first = true;
 
 	FOR_ALL_TRAINS(v) {
 		if (v->First() == v && !(v->vehstatus & VS_CRASHED)) {
@@ -116,7 +117,12 @@
 						SetDParam(1, v->owner);
 						ShowErrorMessage(STR_BROKEN_VEHICLE_LENGTH, INVALID_STRING_ID, WL_CRITICAL);
 
-						if (!_networking) DoCommandP(0, PM_PAUSED_ERROR, 1, CMD_PAUSE);
+						if (!_networking && first) {
+							first = false;
+							DoCommandP(0, PM_PAUSED_ERROR, 1, CMD_PAUSE);
+						}
+						/* Break so we warn only once for each train. */
+						break;
 					}
 				}
 			}