summaryrefslogtreecommitdiff
path: root/src/order_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-10 08:30:15 +0000
committerrubidium <rubidium@openttd.org>2008-04-10 08:30:15 +0000
commite61dcab79d9dc3eba0b24094ee108606c970eac2 (patch)
tree81b8383f4d20454c1546e1f654d36905a9980922 /src/order_cmd.cpp
parent79cb5ec1c70e1661db721a9b5a1e21a375989a30 (diff)
downloadopenttd-e61dcab79d9dc3eba0b24094ee108606c970eac2.tar.xz
(svn r12648) -Feature: allow four different non-stop types in a single game instead of two. The "TTDP compatible order" setting now only sets the default behaviour of new trains.
-Feature: allow three different load type in a single game instead of two. One can choose full load all and full load any instead of full load being governed by the "full load any" patch setting.
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp63
1 files changed, 43 insertions, 20 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index cea569137..60064fae0 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -41,21 +41,6 @@ BackuppedOrders _backup_orders_data;
DEFINE_OLD_POOL_GENERIC(Order, Order);
-OrderLoadFlags Order::GetLoadType() const
-{
- if ((this->flags & OLFB_FULL_LOAD) == 0) return OLF_LOAD_IF_POSSIBLE;
- return _patches.full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD;
-}
-
-OrderNonStopFlags Order::GetNonStopType() const
-{
- if (_patches.new_nonstop) {
- return (this->flags & 0x08) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
- }
-
- return (this->flags & 0x08) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE;
-}
-
void Order::Free()
{
this->type = OT_NOTHING;
@@ -157,6 +142,45 @@ Order::Order(uint32 packed)
this->travel_time = 0;
}
+void Order::ConvertFromOldSavegame()
+{
+ /* First handle non-stop, because those bits are going to be reused. */
+ if (_patches.sg_new_nonstop) {
+ this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_ANY_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+ } else {
+ this->SetNonStopType((this->flags & 0x08) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
+ }
+
+ switch (this->GetType()) {
+ /* Only a few types need the other savegame conversions. */
+ case OT_GOTO_DEPOT: case OT_GOTO_STATION: case OT_LOADING: break;
+ default: return;
+ }
+
+ /* Then the load/depot action flags because those bits are going to be reused too
+ * and they reuse the non-stop bits. */
+ if (this->GetType() != OT_GOTO_DEPOT) {
+ if ((this->flags & 4) == 0) {
+ this->SetLoadType(OLF_LOAD_IF_POSSIBLE);
+ } else {
+ this->SetLoadType(_patches.sg_full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD);
+ }
+ } else {
+ this->SetDepotActionType(((this->flags & 6) == 4) ? ODATFB_HALT : ODATF_SERVICE_ONLY);
+ }
+
+ /* Finally fix the unload/depot type flags. */
+ if (this->GetType() != OT_GOTO_DEPOT) {
+ uint t = ((this->flags & 1) == 0) ? OUF_UNLOAD_IF_POSSIBLE : OUFB_TRANSFER;
+ if ((this->flags & 2) != 0) t |= OUFB_UNLOAD;
+ this->SetUnloadType((OrderUnloadFlags)t);
+ } else {
+ uint t = ((this->flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL;
+ if ((this->flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS;
+ this->SetDepotOrderType((OrderDepotTypeFlags)t);
+ }
+}
+
/**
*
* Unpacks a order from savegames with version 4 and lower
@@ -322,7 +346,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
/* Non stop not allowed for non-trains. */
- // TODO: implement properly once savegame bump is done. if ((new_order.GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) != 0 && v->type != VEH_TRAIN) return CMD_ERROR;
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
/* Full load and unload are mutual exclusive. */
if ((new_order.GetLoadType() & OLFB_FULL_LOAD) && (new_order.GetUnloadType() & OUFB_UNLOAD)) return CMD_ERROR;
@@ -372,7 +396,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
}
- // TODO: implement properly once savegame bump is done. if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
if (new_order.GetDepotOrderType() & ~ODTFB_PART_OF_ORDERS) return CMD_ERROR;
if (new_order.GetDepotActionType() & ~ODATFB_HALT) return CMD_ERROR;
break;
@@ -390,8 +414,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Order flags can be any of the following for waypoints:
* [non-stop]
* non-stop orders (if any) are only valid for trains */
- // TODO: implement properly once savegame bump is done. if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
-
+ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
break;
}
@@ -778,7 +801,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
break;
case MOF_LOAD:
- if ((data & ~OLFB_FULL_LOAD) != 0) return CMD_ERROR;
+ if (data > OLF_FULL_LOAD_ANY || data == 1) return CMD_ERROR;
if (data == order->GetLoadType()) return CMD_ERROR;
break;