1
0
Fork 0

(svn r2034) -Codechange: Replaced the rather meaningless LOAD and UNLOAD flags for depots by something more meaningful

release/0.4.5
celestar 2005-03-20 08:43:29 +00:00
parent 087d78d465
commit fbc2eacade
6 changed files with 40 additions and 26 deletions

View File

@ -575,7 +575,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
return; return;
if (v->current_order.type == OT_GOTO_DEPOT && if (v->current_order.type == OT_GOTO_DEPOT &&
v->current_order.flags & OF_FULL_LOAD) v->current_order.flags & OF_HALT_IN_DEPOT)
return; return;
if (_patches.gotodepot && VehicleHasDepotOrders(v)) if (_patches.gotodepot && VehicleHasDepotOrders(v))
@ -1313,9 +1313,9 @@ static void AircraftEnterHangar(Vehicle *v)
v->current_order.type = OT_NOTHING; v->current_order.type = OT_NOTHING;
v->current_order.flags = 0; v->current_order.flags = 0;
if (old_order.flags & OF_UNLOAD) { if (HASBIT(old_order.flags, OFB_PART_OF_ORDERS)) {
v->cur_order_index++; v->cur_order_index++;
} else if (old_order.flags & OF_FULL_LOAD) { // force depot visit } else if (HASBIT(old_order.flags, OFB_HALT_IN_DEPOT)) { // force depot visit
v->vehstatus |= VS_STOPPED; v->vehstatus |= VS_STOPPED;
InvalidateWindowClasses(WC_AIRCRAFT_LIST); InvalidateWindowClasses(WC_AIRCRAFT_LIST);

19
order.h
View File

@ -16,16 +16,25 @@ enum {
/* Order flags -- please use OFB instead OF and use HASBIT/SETBIT/CLEARBIT */ /* Order flags -- please use OFB instead OF and use HASBIT/SETBIT/CLEARBIT */
enum { enum {
OF_UNLOAD = 0x2, //Flags for stations:
OF_FULL_LOAD = 0x4, // Also used when to force an aircraft into a depot OF_UNLOAD = 0x2,
OF_FULL_LOAD = 0x4, // Also used when to force an aircraft into a depot
//Flags for depots:
OF_PART_OF_ORDERS = 0x2,
OF_HALT_IN_DEPOT = 0x4,
//Common flags
OF_NON_STOP = 0x8 OF_NON_STOP = 0x8
}; };
/* Order flags bits */ /* Order flags bits */
enum { enum {
OFB_UNLOAD = 1, OFB_UNLOAD = 1,
OFB_FULL_LOAD = 2, OFB_FULL_LOAD = 2,
OFB_NON_STOP = 3 OFB_PART_OF_ORDERS = 1,
OFB_HALT_IN_DEPOT = 2,
OFB_NON_STOP = 3
}; };
/* Possible clone options */ /* Possible clone options */

View File

@ -167,7 +167,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
if (v->type == VEH_Train && _map_owner[tile] == _local_player) { if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
if ((_map5[tile]&0xFC)==0xC0) { if ((_map5[tile]&0xFC)==0xC0) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index; order.station = GetDepotByTile(tile)->index;
return order; return order;
} }
@ -177,7 +177,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
case MP_STREET: case MP_STREET:
if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) { if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index; order.station = GetDepotByTile(tile)->index;
return order; return order;
} }
@ -187,7 +187,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
if (v->type != VEH_Aircraft) break; if (v->type != VEH_Aircraft) break;
if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) { if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) {
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD | OF_NON_STOP; order.flags = OF_PART_OF_ORDERS | OF_NON_STOP; //XXX - whats the nonstop stuff doing here?
order.station = _map2[tile]; order.station = _map2[tile];
return order; return order;
} }
@ -202,7 +202,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
case 0x83: tile-= TILE_XY(0,1); break; case 0x83: tile-= TILE_XY(0,1); break;
} }
order.type = OT_GOTO_DEPOT; order.type = OT_GOTO_DEPOT;
order.flags = OF_UNLOAD; order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index; order.station = GetDepotByTile(tile)->index;
return order; return order;
} }

View File

@ -334,8 +334,10 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->current_order.type == OT_GOTO_DEPOT) { if (v->current_order.type == OT_GOTO_DEPOT) {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (v->current_order.flags & OF_UNLOAD)
if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
v->cur_order_index++; v->cur_order_index++;
v->current_order.type = OT_DUMMY; v->current_order.type = OT_DUMMY;
v->current_order.flags = 0; v->current_order.flags = 0;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@ -349,7 +351,7 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD; v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
v->current_order.station = depot->index; v->current_order.station = depot->index;
v->dest_tile = depot->xy; v->dest_tile = depot->xy;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@ -1531,9 +1533,9 @@ void RoadVehEnterDepot(Vehicle *v)
v->current_order.flags = 0; v->current_order.flags = 0;
// Part of the orderlist? // Part of the orderlist?
if (t.flags & OF_UNLOAD) { if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
v->cur_order_index++; v->cur_order_index++;
} else if (t.flags & OF_FULL_LOAD) { } else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
v->vehstatus |= VS_STOPPED; v->vehstatus |= VS_STOPPED;
if (v->owner == _local_player) { if (v->owner == _local_player) {
SetDParam(0, v->unitnumber); SetDParam(0, v->unitnumber);
@ -1583,7 +1585,7 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
// Don't interfere with a depot visit scheduled by the user, or a // Don't interfere with a depot visit scheduled by the user, or a
// depot visit by the order list. // depot visit by the order list.
if (v->current_order.type == OT_GOTO_DEPOT && if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_FULL_LOAD | OF_UNLOAD)) != 0) (v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
return; return;
//If we already got a slot at a stop, use that FIRST, and go to a depot later //If we already got a slot at a stop, use that FIRST, and go to a depot later

View File

@ -108,7 +108,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
return; return;
if (v->current_order.type == OT_GOTO_DEPOT && if (v->current_order.type == OT_GOTO_DEPOT &&
v->current_order.flags & OF_FULL_LOAD) v->current_order.flags & OF_HALT_IN_DEPOT)
return; return;
if (_patches.gotodepot && VehicleHasDepotOrders(v)) if (_patches.gotodepot && VehicleHasDepotOrders(v))
@ -430,9 +430,9 @@ static void ShipEnterDepot(Vehicle *v)
v->current_order.type = OT_DUMMY; v->current_order.type = OT_DUMMY;
v->current_order.flags = 0; v->current_order.flags = 0;
if (t.flags & OF_UNLOAD) { if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
v->cur_order_index++; v->cur_order_index++;
} else if (t.flags & OF_FULL_LOAD) { } else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
v->vehstatus |= VS_STOPPED; v->vehstatus |= VS_STOPPED;
if (v->owner == _local_player) { if (v->owner == _local_player) {
SetDParam(0, v->unitnumber); SetDParam(0, v->unitnumber);
@ -993,7 +993,10 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->current_order.type == OT_GOTO_DEPOT) { if (v->current_order.type == OT_GOTO_DEPOT) {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (v->current_order.flags & OF_UNLOAD) v->cur_order_index++;
if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS))
v->cur_order_index++;
v->current_order.type = OT_DUMMY; v->current_order.type = OT_DUMMY;
v->current_order.flags = 0; v->current_order.flags = 0;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@ -1006,7 +1009,7 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
v->dest_tile = depot->xy; v->dest_tile = depot->xy;
v->current_order.type = OT_GOTO_DEPOT; v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP | OF_FULL_LOAD; v->current_order.flags = OF_NON_STOP | OF_HALT_IN_DEPOT;
v->current_order.station = depot->index; v->current_order.station = depot->index;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
} }

View File

@ -1353,7 +1353,7 @@ int32 CmdTrainGotoDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->current_order.type == OT_GOTO_DEPOT) { if (v->current_order.type == OT_GOTO_DEPOT) {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
if (v->current_order.flags & OF_UNLOAD) { if (HASBIT(v->current_order.flags, OF_PART_OF_ORDERS)) {
v->u.rail.days_since_order_progr = 0; v->u.rail.days_since_order_progr = 0;
v->cur_order_index++; v->cur_order_index++;
} }
@ -2956,10 +2956,10 @@ void TrainEnterDepot(Vehicle *v, uint tile)
v->current_order.type = OT_DUMMY; v->current_order.type = OT_DUMMY;
v->current_order.flags = 0; v->current_order.flags = 0;
if (t.flags & OF_UNLOAD) { // Part of the orderlist? if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) { // Part of the orderlist?
v->u.rail.days_since_order_progr = 0; v->u.rail.days_since_order_progr = 0;
v->cur_order_index++; v->cur_order_index++;
} else if (t.flags & OF_FULL_LOAD) { // User initiated? } else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) { // User initiated?
v->vehstatus |= VS_STOPPED; v->vehstatus |= VS_STOPPED;
if (v->owner == _local_player) { if (v->owner == _local_player) {
SetDParam(0, v->unitnumber); SetDParam(0, v->unitnumber);
@ -2995,7 +2995,7 @@ static void CheckIfTrainNeedsService(Vehicle *v)
// Don't interfere with a depot visit scheduled by the user, or a // Don't interfere with a depot visit scheduled by the user, or a
// depot visit by the order list. // depot visit by the order list.
if (v->current_order.type == OT_GOTO_DEPOT && if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_FULL_LOAD | OF_UNLOAD)) != 0) (v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
return; return;
tfdd = FindClosestTrainDepot(v); tfdd = FindClosestTrainDepot(v);