130 if (total_power == 0) v->vehstatus |= VS_STOPPED; |
130 if (total_power == 0) v->vehstatus |= VS_STOPPED; |
131 |
131 |
132 v->u.rail.cached_power = total_power; |
132 v->u.rail.cached_power = total_power; |
133 v->u.rail.cached_max_te = max_te; |
133 v->u.rail.cached_max_te = max_te; |
134 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
134 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
135 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
135 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
136 } |
136 } |
137 } |
137 } |
138 |
138 |
139 |
139 |
140 /** |
140 /** |
1245 if (IsFrontEngine(src_head)) { |
1245 if (IsFrontEngine(src_head)) { |
1246 UpdateTrainAcceleration(src_head); |
1246 UpdateTrainAcceleration(src_head); |
1247 InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index); |
1247 InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index); |
1248 /* Update the refit button and window */ |
1248 /* Update the refit button and window */ |
1249 InvalidateWindow(WC_VEHICLE_REFIT, src_head->index); |
1249 InvalidateWindow(WC_VEHICLE_REFIT, src_head->index); |
1250 InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, 12); |
1250 InvalidateWindowWidget(WC_VEHICLE_VIEW, src_head->index, VVW_WIDGET_REFIT_VEH); |
1251 } |
1251 } |
1252 /* Update the depot window */ |
1252 /* Update the depot window */ |
1253 InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile); |
1253 InvalidateWindow(WC_VEHICLE_DEPOT, src_head->tile); |
1254 } |
1254 } |
1255 |
1255 |
1259 UpdateTrainGroupID(dst_head); |
1259 UpdateTrainGroupID(dst_head); |
1260 if (IsFrontEngine(dst_head)) { |
1260 if (IsFrontEngine(dst_head)) { |
1261 UpdateTrainAcceleration(dst_head); |
1261 UpdateTrainAcceleration(dst_head); |
1262 InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index); |
1262 InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index); |
1263 /* Update the refit button and window */ |
1263 /* Update the refit button and window */ |
1264 InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, 12); |
1264 InvalidateWindowWidget(WC_VEHICLE_VIEW, dst_head->index, VVW_WIDGET_REFIT_VEH); |
1265 InvalidateWindow(WC_VEHICLE_REFIT, dst_head->index); |
1265 InvalidateWindow(WC_VEHICLE_REFIT, dst_head->index); |
1266 } |
1266 } |
1267 /* Update the depot window */ |
1267 /* Update the depot window */ |
1268 InvalidateWindow(WC_VEHICLE_DEPOT, dst_head->tile); |
1268 InvalidateWindow(WC_VEHICLE_DEPOT, dst_head->tile); |
1269 } |
1269 } |
1302 if (v->vehstatus & VS_STOPPED && v->u.rail.track == TRACK_BIT_DEPOT) { |
1302 if (v->vehstatus & VS_STOPPED && v->u.rail.track == TRACK_BIT_DEPOT) { |
1303 DeleteVehicleNews(p1, STR_8814_TRAIN_IS_WAITING_IN_DEPOT); |
1303 DeleteVehicleNews(p1, STR_8814_TRAIN_IS_WAITING_IN_DEPOT); |
1304 } |
1304 } |
1305 |
1305 |
1306 v->vehstatus ^= VS_STOPPED; |
1306 v->vehstatus ^= VS_STOPPED; |
1307 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1307 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
1308 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
1308 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
1309 } |
1309 } |
1310 return CommandCost(); |
1310 return CommandCost(); |
1311 } |
1311 } |
1312 |
1312 |
1547 { |
1547 { |
1548 int old = v->u.rail.last_speed; |
1548 int old = v->u.rail.last_speed; |
1549 if (spd != old) { |
1549 if (spd != old) { |
1550 v->u.rail.last_speed = spd; |
1550 v->u.rail.last_speed = spd; |
1551 if (_patches.vehicle_speed || (old == 0) != (spd == 0)) |
1551 if (_patches.vehicle_speed || (old == 0) != (spd == 0)) |
1552 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
1552 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
1553 } |
1553 } |
1554 } |
1554 } |
1555 |
1555 |
1556 static void SwapTrainFlags(byte *swap_flag1, byte *swap_flag2) |
1556 static void SwapTrainFlags(byte *swap_flag1, byte *swap_flag2) |
1557 { |
1557 { |
2060 * Now we change the setting to apply the new one and let the vehicle head for the same depot. |
2060 * Now we change the setting to apply the new one and let the vehicle head for the same depot. |
2061 * Note: the if is (true for requesting service == true for ordered to stop in depot) */ |
2061 * Note: the if is (true for requesting service == true for ordered to stop in depot) */ |
2062 if (flags & DC_EXEC) { |
2062 if (flags & DC_EXEC) { |
2063 ClrBit(v->current_order.flags, OF_PART_OF_ORDERS); |
2063 ClrBit(v->current_order.flags, OF_PART_OF_ORDERS); |
2064 ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT); |
2064 ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT); |
2065 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
2065 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
2066 } |
2066 } |
2067 return CommandCost(); |
2067 return CommandCost(); |
2068 } |
2068 } |
2069 |
2069 |
2070 if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders |
2070 if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders |
2073 v->cur_order_index++; |
2073 v->cur_order_index++; |
2074 } |
2074 } |
2075 |
2075 |
2076 v->current_order.type = OT_DUMMY; |
2076 v->current_order.type = OT_DUMMY; |
2077 v->current_order.flags = 0; |
2077 v->current_order.flags = 0; |
2078 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
2078 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
2079 } |
2079 } |
2080 return CommandCost(); |
2080 return CommandCost(); |
2081 } |
2081 } |
2082 |
2082 |
2083 /* check if at a standstill (not stopped only) in a depot |
2083 /* check if at a standstill (not stopped only) in a depot |
2094 v->current_order.type = OT_GOTO_DEPOT; |
2094 v->current_order.type = OT_GOTO_DEPOT; |
2095 v->current_order.flags = OFB_NON_STOP; |
2095 v->current_order.flags = OFB_NON_STOP; |
2096 if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT); |
2096 if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT); |
2097 v->current_order.dest = GetDepotByTile(tfdd.tile)->index; |
2097 v->current_order.dest = GetDepotByTile(tfdd.tile)->index; |
2098 v->current_order.refit_cargo = CT_INVALID; |
2098 v->current_order.refit_cargo = CT_INVALID; |
2099 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
2099 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
2100 /* If there is no depot in front, reverse automatically */ |
2100 /* If there is no depot in front, reverse automatically */ |
2101 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); |
2101 if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); |
2102 } |
2102 } |
2103 |
2103 |
2104 return CommandCost(); |
2104 return CommandCost(); |
2842 /* we may need to update crossing we were approaching */ |
2842 /* we may need to update crossing we were approaching */ |
2843 TileIndex crossing = TrainApproachingCrossingTile(v); |
2843 TileIndex crossing = TrainApproachingCrossingTile(v); |
2844 |
2844 |
2845 v->u.rail.crash_anim_pos++; |
2845 v->u.rail.crash_anim_pos++; |
2846 |
2846 |
2847 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
2847 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
2848 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
2848 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
2849 |
2849 |
2850 if (v->u.rail.track == TRACK_BIT_DEPOT) { |
2850 if (v->u.rail.track == TRACK_BIT_DEPOT) { |
2851 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
2851 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
2852 } |
2852 } |
3586 /* If we were already heading for a depot but it has |
3586 /* If we were already heading for a depot but it has |
3587 * suddenly moved farther away, we continue our normal |
3587 * suddenly moved farther away, we continue our normal |
3588 * schedule? */ |
3588 * schedule? */ |
3589 v->current_order.type = OT_DUMMY; |
3589 v->current_order.type = OT_DUMMY; |
3590 v->current_order.flags = 0; |
3590 v->current_order.flags = 0; |
3591 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
3591 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
3592 } |
3592 } |
3593 return; |
3593 return; |
3594 } |
3594 } |
3595 |
3595 |
3596 const Depot* depot = GetDepotByTile(tfdd.tile); |
3596 const Depot* depot = GetDepotByTile(tfdd.tile); |
3603 |
3603 |
3604 v->current_order.type = OT_GOTO_DEPOT; |
3604 v->current_order.type = OT_GOTO_DEPOT; |
3605 v->current_order.flags = OFB_NON_STOP; |
3605 v->current_order.flags = OFB_NON_STOP; |
3606 v->current_order.dest = depot->index; |
3606 v->current_order.dest = depot->index; |
3607 v->dest_tile = tfdd.tile; |
3607 v->dest_tile = tfdd.tile; |
3608 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
3608 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
3609 } |
3609 } |
3610 |
3610 |
3611 void OnNewDay_Train(Vehicle *v) |
3611 void OnNewDay_Train(Vehicle *v) |
3612 { |
3612 { |
3613 if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); |
3613 if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v); |