equal
deleted
inserted
replaced
3346 |
3346 |
3347 #define MAX_ACCEPTABLE_DEPOT_DIST 16 |
3347 #define MAX_ACCEPTABLE_DEPOT_DIST 16 |
3348 |
3348 |
3349 static void CheckIfTrainNeedsService(Vehicle *v) |
3349 static void CheckIfTrainNeedsService(Vehicle *v) |
3350 { |
3350 { |
3351 if (_patches.servint_trains == 0) return; |
3351 if (_patches.servint_trains == 0 || !VehicleNeedsService(v)) return; |
3352 if (!VehicleNeedsService(v)) return; |
3352 if (v->IsInDepot()) { |
3353 if (v->vehstatus & VS_STOPPED) return; |
|
3354 if (_patches.gotodepot && VehicleHasDepotOrders(v)) return; |
|
3355 |
|
3356 /* Don't interfere with a depot visit scheduled by the user, or a |
|
3357 * depot visit by the order list. */ |
|
3358 if (v->current_order.type == OT_GOTO_DEPOT && |
|
3359 (v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0) |
|
3360 return; |
|
3361 |
|
3362 if (CheckTrainIsInsideDepot(v)) { |
|
3363 VehicleServiceInDepot(v); |
3353 VehicleServiceInDepot(v); |
3364 return; |
3354 return; |
3365 } |
3355 } |
3366 |
3356 |
3367 TrainFindDepotData tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); |
3357 TrainFindDepotData tfdd = FindClosestTrainDepot(v, MAX_ACCEPTABLE_DEPOT_DIST); |
3383 if (v->current_order.type == OT_GOTO_DEPOT && |
3373 if (v->current_order.type == OT_GOTO_DEPOT && |
3384 v->current_order.dest != depot->index && |
3374 v->current_order.dest != depot->index && |
3385 !CHANCE16(3, 16)) { |
3375 !CHANCE16(3, 16)) { |
3386 return; |
3376 return; |
3387 } |
3377 } |
3388 |
|
3389 if (v->current_order.type == OT_LOADING) v->LeaveStation(); |
|
3390 |
3378 |
3391 v->current_order.type = OT_GOTO_DEPOT; |
3379 v->current_order.type = OT_GOTO_DEPOT; |
3392 v->current_order.flags = OF_NON_STOP; |
3380 v->current_order.flags = OF_NON_STOP; |
3393 v->current_order.dest = depot->index; |
3381 v->current_order.dest = depot->index; |
3394 v->dest_tile = tfdd.tile; |
3382 v->dest_tile = tfdd.tile; |