comparison src/train_cmd.cpp @ 8853:02787d6f3834 draft

(svn r12615) -Codechange: rename some enums related to depot orders to make it more clear that they are no loading/unloading flags. Also add more type strictness.
author rubidium <rubidium@openttd.org>
date Mon, 07 Apr 2008 19:18:56 +0000
parents 4859a9c43de3
children 1300bc87c872
comparison
equal deleted inserted replaced
8852:33c1c0e676a3 8853:02787d6f3834
2107 if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR; 2107 if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
2108 2108
2109 if (v->vehstatus & VS_CRASHED) return CMD_ERROR; 2109 if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
2110 2110
2111 if (v->current_order.IsType(OT_GOTO_DEPOT)) { 2111 if (v->current_order.IsType(OT_GOTO_DEPOT)) {
2112 bool halt_in_depot = HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT); 2112 bool halt_in_depot = v->current_order.GetDepotActionType() & ODATFB_HALT;
2113 if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) { 2113 if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) {
2114 /* We called with a different DEPOT_SERVICE setting. 2114 /* We called with a different DEPOT_SERVICE setting.
2115 * Now we change the setting to apply the new one and let the vehicle head for the same depot. 2115 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
2116 * Note: the if is (true for requesting service == true for ordered to stop in depot) */ 2116 * Note: the if is (true for requesting service == true for ordered to stop in depot) */
2117 if (flags & DC_EXEC) { 2117 if (flags & DC_EXEC) {
2118 v->current_order.SetDepotOrderType(OFB_MANUAL_ORDER); 2118 v->current_order.SetDepotOrderType(ODTF_MANUAL);
2119 v->current_order.SetDepotActionType(halt_in_depot ? OFB_NORMAL_ACTION : OFB_HALT_IN_DEPOT); 2119 v->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
2120 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); 2120 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
2121 } 2121 }
2122 return CommandCost(); 2122 return CommandCost();
2123 } 2123 }
2124 2124
2125 if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders 2125 if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
2126 if (flags & DC_EXEC) { 2126 if (flags & DC_EXEC) {
2127 /* If the orders to 'goto depot' are in the orders list (forced servicing), 2127 /* If the orders to 'goto depot' are in the orders list (forced servicing),
2128 * then skip to the next order; effectively cancelling this forced service */ 2128 * then skip to the next order; effectively cancelling this forced service */
2129 if (v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS) v->cur_order_index++; 2129 if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) v->cur_order_index++;
2130 2130
2131 v->current_order.MakeDummy(); 2131 v->current_order.MakeDummy();
2132 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); 2132 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
2133 } 2133 }
2134 return CommandCost(); 2134 return CommandCost();
2143 2143
2144 if (flags & DC_EXEC) { 2144 if (flags & DC_EXEC) {
2145 if (v->current_order.IsType(OT_LOADING)) v->LeaveStation(); 2145 if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
2146 2146
2147 v->dest_tile = tfdd.tile; 2147 v->dest_tile = tfdd.tile;
2148 v->current_order.MakeGoToDepot(GetDepotByTile(tfdd.tile)->index, false); 2148 v->current_order.MakeGoToDepot(GetDepotByTile(tfdd.tile)->index, ODTF_MANUAL);
2149 if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(OFB_HALT_IN_DEPOT); 2149 if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(ODATFB_HALT);
2150 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); 2150 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
2151 /* If there is no depot in front, reverse automatically */ 2151 /* If there is no depot in front, reverse automatically */
2152 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); 2152 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
2153 } 2153 }
2154 2154
3568 v->current_order.GetDestination() != depot->index && 3568 v->current_order.GetDestination() != depot->index &&
3569 !Chance16(3, 16)) { 3569 !Chance16(3, 16)) {
3570 return; 3570 return;
3571 } 3571 }
3572 3572
3573 v->current_order.MakeGoToDepot(depot->index, false); 3573 v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
3574 v->dest_tile = tfdd.tile; 3574 v->dest_tile = tfdd.tile;
3575 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); 3575 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
3576 } 3576 }
3577 3577
3578 void Train::OnNewDay() 3578 void Train::OnNewDay()