(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
authorrubidium
Sun, 23 Nov 2008 21:46:27 +0000
changeset 10365 6d492bcbff99
parent 10364 20835b95acad
child 10366 74b3472edfa4
(svn r14616) -Fix [FS#2424]: a nearest depot order should be "equal" to the resolved nearest depot order; otherwise we keep resolving the nearest depot order every tick.
src/order_cmd.cpp
--- a/src/order_cmd.cpp	Sun Nov 23 18:07:49 2008 +0000
+++ b/src/order_cmd.cpp	Sun Nov 23 21:46:27 2008 +0000
@@ -115,6 +115,19 @@
 
 bool Order::Equals(const Order &other) const
 {
+	/* In case of go to nearest depot orders we need "only" compare the flags
+	 * with the other and not the nearest depot order bit or the actual
+	 * destination because those get clear/filled in during the order
+	 * evaluation. If we do not do this the order will continuously be seen as
+	 * a different order and it will try to find a "nearest depot" every tick. */
+	if ((this->type == OT_GOTO_DEPOT && this->type == other.type) &&
+			((this->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0 ||
+			 (other.GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0)) {
+		return
+			this->GetDepotOrderType() == other.GetDepotOrderType() &&
+			(this->GetDepotActionType() & ~ODATFB_NEAREST_DEPOT) == (other.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT);
+	}
+
 	return
 			this->type  == other.type &&
 			this->flags == other.flags &&