summaryrefslogtreecommitdiff
path: root/order_cmd.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-09-16 16:03:18 +0000
committerDarkvater <darkvater@openttd.org>2005-09-16 16:03:18 +0000
commitc930f8f8c0c60e192e50db9a032e55ff671db131 (patch)
treef3163c8df242274577a2a6eb8c73a89224ad0e1a /order_cmd.c
parent4797310f91579b0cbf6cbce8a3ab85654d4d3f22 (diff)
downloadopenttd-c930f8f8c0c60e192e50db9a032e55ff671db131.tar.xz
(svn r2959) - Fix: [ 1266036 ] Fix [ 1236317 ] Vehicles with and TRANSFER order don't have that order restored (i_dachev). Also disallow non-train type vehicles to have non-stop orders.
Diffstat (limited to 'order_cmd.c')
-rw-r--r--order_cmd.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/order_cmd.c b/order_cmd.c
index 6c97dd43d..882f119b1 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -2,6 +2,7 @@
#include "stdafx.h"
#include "openttd.h"
+#include "order.h"
#include "airport.h"
#include "depot.h"
#include "functions.h"
@@ -202,13 +203,25 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
default: return CMD_ERROR;
}
+ /* Order flags can be any of the following for stations:
+ * [full-load | unload] [+ transfer] [+ non-stop]
+ * non-stop orders (if any) are only valid for trains */
switch (new_order.flags) {
- case 0:
+ case 0: /* Fallthrough */
case OF_FULL_LOAD:
+ case OF_FULL_LOAD | OF_TRANSFER: /* Fallthrough */
case OF_UNLOAD:
+ case OF_UNLOAD | OF_TRANSFER: /* Fallthrough */
+ case OF_TRANSFER:
+ break;
+
case OF_NON_STOP:
case OF_NON_STOP | OF_FULL_LOAD:
+ case OF_NON_STOP | OF_FULL_LOAD | OF_TRANSFER: /* Fallthrough */
case OF_NON_STOP | OF_UNLOAD:
+ case OF_NON_STOP | OF_UNLOAD | OF_TRANSFER: /* Fallthrough */
+ case OF_NON_STOP | OF_TRANSFER:
+ if (v->type != VEH_Train) return CMD_ERROR;
break;
default: return CMD_ERROR;
@@ -235,10 +248,8 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsDepotIndex(new_order.station)) return CMD_ERROR;
dp = GetDepot(new_order.station);
- if (!IsValidDepot(dp) ||
- !CheckOwnership(GetTileOwner(dp->xy))) {
+ if (!IsValidDepot(dp) || !CheckOwnership(GetTileOwner(dp->xy)))
return CMD_ERROR;
- }
switch (v->type) {
case VEH_Train:
@@ -257,11 +268,17 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
}
+ /* Order flags can be any of the following for depots:
+ * order [+ halt] [+ non-stop]
+ * non-stop orders (if any) are only valid for trains */
switch (new_order.flags) {
case OF_PART_OF_ORDERS:
case OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT:
+ break;
+
case OF_NON_STOP | OF_PART_OF_ORDERS:
case OF_NON_STOP | OF_PART_OF_ORDERS | OF_HALT_IN_DEPOT:
+ if (v->type != VEH_Train) return CMD_ERROR;
break;
default: return CMD_ERROR;
@@ -279,9 +296,14 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
+ /* Order flags can be any of the following for waypoints:
+ * [non-stop]
+ * non-stop orders (if any) are only valid for trains */
switch (new_order.flags) {
- case 0:
+ case 0: break;
+
case OF_NON_STOP:
+ if (v->type != VEH_Train) return CMD_ERROR;
break;
default: return CMD_ERROR;
@@ -298,7 +320,7 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* XXX - This limit is only here because the backuppedorders can't
* handle any more then this.. */
- if (v->num_orders >= 40) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
+ if (v->num_orders >= MAX_BACKUP_ORDER_COUNT) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
/* For ships, make sure that the station is not too far away from the
* previous destination, for human players with new pathfinding disabled */