summaryrefslogtreecommitdiff
path: root/order_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-09-03 08:25:27 +0000
committertron <tron@openttd.org>2006-09-03 08:25:27 +0000
commit1c21c645ae04601cd3711b37e6541d807cb727a7 (patch)
tree79ebec494a87cd0b8e16e577740868f5bf90a7d2 /order_cmd.c
parent302772883ce9dd965ca6dfe9ade85530c6de8210 (diff)
downloadopenttd-1c21c645ae04601cd3711b37e6541d807cb727a7.tar.xz
(svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
DestinationID being a union of these types is just hassle without benefit and cannot be handled correctly everywhere because of local lack of information
Diffstat (limited to 'order_cmd.c')
-rw-r--r--order_cmd.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/order_cmd.c b/order_cmd.c
index 68ed40e5f..ee4981965 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -47,12 +47,12 @@ Order UnpackOldOrder(uint16 packed)
Order order;
order.type = GB(packed, 0, 4);
order.flags = GB(packed, 4, 4);
- order.dest.station = GB(packed, 8, 8);
+ order.dest = GB(packed, 8, 8);
order.next = NULL;
// Sanity check
// TTD stores invalid orders as OT_NOTHING with non-zero flags/station
- if (order.type == OT_NOTHING && (order.flags != 0 || order.dest.station != 0)) {
+ if (order.type == OT_NOTHING && (order.flags != 0 || order.dest != 0)) {
order.type = OT_DUMMY;
order.flags = 0;
}
@@ -68,11 +68,11 @@ Order UnpackOldOrder(uint16 packed)
static Order UnpackVersion4Order(uint16 packed)
{
Order order;
- order.type = GB(packed, 0, 4);
- order.flags = GB(packed, 4, 4);
- order.dest.station = GB(packed, 8, 8);
- order.next = NULL;
- order.index = 0; // avoid compiler warning
+ order.type = GB(packed, 0, 4);
+ order.flags = GB(packed, 4, 4);
+ order.dest = GB(packed, 8, 8);
+ order.next = NULL;
+ order.index = 0; // avoid compiler warning
return order;
}
@@ -142,9 +142,9 @@ static Order *AllocateOrder(void)
*/
void AssignOrder(Order *order, Order data)
{
- order->type = data.type;
- order->flags = data.flags;
- order->dest.station = data.dest.station;
+ order->type = data.type;
+ order->flags = data.flags;
+ order->dest = data.dest;
}
@@ -191,8 +191,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case OT_GOTO_STATION: {
const Station *st;
- if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
- st = GetStation(new_order.dest.station);
+ if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
+ st = GetStation(new_order.dest);
if (st->airport_type != AT_OILRIG && !IsBuoy(st) && !CheckOwnership(st->owner)) {
return CMD_ERROR;
@@ -252,8 +252,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type == VEH_Aircraft) {
const Station* st;
- if (!IsValidStationID(new_order.dest.station)) return CMD_ERROR;
- st = GetStation(new_order.dest.station);
+ if (!IsValidStationID(new_order.dest)) return CMD_ERROR;
+ st = GetStation(new_order.dest);
if ((st->airport_type != AT_OILRIG && !CheckOwnership(st->owner)) ||
!(st->facilities & FACIL_AIRPORT) ||
@@ -263,8 +263,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} else {
const Depot* dp;
- if (!IsValidDepotID(new_order.dest.depot)) return CMD_ERROR;
- dp = GetDepot(new_order.dest.depot);
+ if (!IsValidDepotID(new_order.dest)) return CMD_ERROR;
+ dp = GetDepot(new_order.dest);
if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
@@ -308,8 +308,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->type != VEH_Train) return CMD_ERROR;
- if (!IsValidWaypointID(new_order.dest.waypoint)) return CMD_ERROR;
- wp = GetWaypoint(new_order.dest.waypoint);
+ if (!IsValidWaypointID(new_order.dest)) return CMD_ERROR;
+ wp = GetWaypoint(new_order.dest);
if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
@@ -346,8 +346,8 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
&& !_patches.new_pathfinding_all) {
int dist = DistanceManhattan(
- GetStation(GetVehicleOrder(v, sel_ord - 1)->dest.station)->xy,
- GetStation(new_order.dest.station)->xy // XXX type != OT_GOTO_STATION?
+ GetStation(GetVehicleOrder(v, sel_ord - 1)->dest)->xy,
+ GetStation(new_order.dest)->xy // XXX type != OT_GOTO_STATION?
);
if (dist >= 130)
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
@@ -704,7 +704,7 @@ int32 CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
FOR_VEHICLE_ORDERS(src, order) {
if (order->type == OT_GOTO_STATION) {
- const Station *st = GetStation(order->dest.station);
+ const Station *st = GetStation(order->dest);
if (dst->cargo_type == CT_PASSENGERS) {
if (st->bus_stops != NULL) required_dst = st->bus_stops->xy;
} else {
@@ -919,7 +919,7 @@ void CheckOrders(const Vehicle* v)
}
/* Does station have a load-bay for this vehicle? */
if (order->type == OT_GOTO_STATION) {
- const Station* st = GetStation(order->dest.station);
+ const Station* st = GetStation(order->dest);
TileIndex required_tile = GetStationTileForVehicle(v, st);
n_st++;
@@ -931,9 +931,9 @@ void CheckOrders(const Vehicle* v)
if (v->num_orders > 1) {
const Order* last = GetLastVehicleOrder(v);
- if (v->orders->type == last->type &&
- v->orders->flags == last->flags &&
- v->orders->dest.station == last->dest.station) {
+ if (v->orders->type == last->type &&
+ v->orders->flags == last->flags &&
+ v->orders->dest == last->dest) {
problem_type = 2;
}
}
@@ -973,11 +973,11 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
if (v->orders == NULL) continue;
/* Forget about this station if this station is removed */
- if (v->last_station_visited == destination.station && type == OT_GOTO_STATION)
+ if (v->last_station_visited == destination && type == OT_GOTO_STATION)
v->last_station_visited = INVALID_STATION;
/* Check the current order */
- if (v->current_order.type == type && v->current_order.dest.station == destination.station) {
+ if (v->current_order.type == type && v->current_order.dest == destination) {
/* Mark the order as DUMMY */
v->current_order.type = OT_DUMMY;
v->current_order.flags = 0;
@@ -987,7 +987,7 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
/* Clear the order from the order-list */
need_invalidate = false;
FOR_VEHICLE_ORDERS(v, order) {
- if (order->type == type && order->dest.station == destination.station) {
+ if (order->type == type && order->dest == destination) {
/* Mark the order as DUMMY */
order->type = OT_DUMMY;
order->flags = 0;
@@ -1110,10 +1110,10 @@ void InitializeOrders(void)
}
static const SaveLoad _order_desc[] = {
- SLE_VAR(Order, type, SLE_UINT8),
- SLE_VAR(Order, flags, SLE_UINT8),
- SLE_VAR(Order, dest.station, SLE_UINT16), // Saving one of the union is enough, they all share the same memory
- SLE_REF(Order, next, REF_ORDER),
+ SLE_VAR(Order, type, SLE_UINT8),
+ SLE_VAR(Order, flags, SLE_UINT8),
+ SLE_VAR(Order, dest, SLE_UINT16),
+ SLE_REF(Order, next, REF_ORDER),
// reserve extra space in savegame here. (currently 10 bytes)
SLE_CONDNULL(10, 5, SL_MAX_VERSION),