diff src/train_cmd.cpp @ 10261:486e807fb404 draft

(svn r14492) -Fix [FS#2366] (r14482): Conditional orders could lead to an infinite loop on path look-ahead. Don't refactor things that don't want to be refactored, folks. And some comments can't hurt either.
author michi_cc <michi_cc@openttd.org>
date Sun, 19 Oct 2008 17:16:26 +0000 (2008-10-19)
parents d0582ee8991e
children 9f1f7dad1803
line wrap: on
line diff
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2857,6 +2857,7 @@
 					VehicleOrderID next = ProcessConditionalOrder(order, this->v);
 					if (next != INVALID_VEH_ORDER_ID) {
 						this->index = next;
+						/* Don't increment next, so no break here. */
 						continue;
 					}
 					break;
@@ -2864,7 +2865,10 @@
 				default:
 					break;
 			}
-		} while (++this->index != this->v->cur_order_index);
+			/* Don't increment inside the while because otherwise conditional
+			 * orders can lead to an infinite loop. */
+			++this->index;
+		} while (this->index != this->v->cur_order_index);
 
 		return false;
 	}