20 { |
22 { |
21 Vehicle *v, *found; |
23 Vehicle *v, *found; |
22 |
24 |
23 if (!success) return; |
25 if (!success) return; |
24 |
26 |
25 // find a locomotive in the depot. |
27 /* find a locomotive in the depot. */ |
26 found = NULL; |
28 found = NULL; |
27 FOR_ALL_VEHICLES(v) { |
29 FOR_ALL_VEHICLES(v) { |
28 if (v->type == VEH_TRAIN && IsFrontEngine(v) && |
30 if (v->type == VEH_TRAIN && IsFrontEngine(v) && |
29 v->tile == tile && |
31 v->tile == tile && |
30 v->u.rail.track == TRACK_BIT_DEPOT) { |
32 v->u.rail.track == TRACK_BIT_DEPOT) { |
31 if (found != NULL) return; // must be exactly one. |
33 if (found != NULL) return; // must be exactly one. |
32 found = v; |
34 found = v; |
33 } |
35 } |
34 } |
36 } |
35 |
37 |
36 // if we found a loco, |
38 /* if we found a loco, */ |
37 if (found != NULL) { |
39 if (found != NULL) { |
38 found = GetLastVehicleInChain(found); |
40 found = GetLastVehicleInChain(found); |
39 // put the new wagon at the end of the loco. |
41 /* put the new wagon at the end of the loco. */ |
40 DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
42 DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
41 RebuildVehicleLists(); |
43 RebuildVehicleLists(); |
42 } |
44 } |
43 } |
45 } |
44 |
46 |
445 DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
447 DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
446 |
448 |
447 y = 57; |
449 y = 57; |
448 sel = w->vscroll.pos; |
450 sel = w->vscroll.pos; |
449 |
451 |
450 // draw the first 3 details tabs |
452 /* draw the first 3 details tabs */ |
451 if (det_tab != 3) { |
453 if (det_tab != 3) { |
452 x = 1; |
454 x = 1; |
453 for (;;) { |
455 for (;;) { |
454 if (--sel < 0 && sel >= -w->vscroll.cap) { |
456 if (--sel < 0 && sel >= -w->vscroll.cap) { |
455 int dx = 0; |
457 int dx = 0; |
468 py = y + 2; |
470 py = y + 2; |
469 switch (det_tab) { |
471 switch (det_tab) { |
470 default: NOT_REACHED(); |
472 default: NOT_REACHED(); |
471 case 0: TrainDetailsCargoTab( v, px, py); break; |
473 case 0: TrainDetailsCargoTab( v, px, py); break; |
472 case 1: |
474 case 1: |
473 // Only show name and value for the 'real' part |
475 /* Only show name and value for the 'real' part */ |
474 if (!IsArticulatedPart(v)) { |
476 if (!IsArticulatedPart(v)) { |
475 TrainDetailsInfoTab(v, px, py); |
477 TrainDetailsInfoTab(v, px, py); |
476 } |
478 } |
477 break; |
479 break; |
478 case 2: TrainDetailsCapacityTab(v, px, py); break; |
480 case 2: TrainDetailsCapacityTab(v, px, py); break; |
479 } |
481 } |
480 y += 14; |
482 y += 14; |
481 |
483 |
482 v = u; |
484 v = u; |
483 } else { |
485 } else { |
484 // Move to the next line |
486 /* Move to the next line */ |
485 do { |
487 do { |
486 v = v->next; |
488 v = v->next; |
487 } while (v != NULL && IsArticulatedPart(v) && v->cargo_cap == 0); |
489 } while (v != NULL && IsArticulatedPart(v) && v->cargo_cap == 0); |
488 } |
490 } |
489 if (v == NULL) return; |
491 if (v == NULL) return; |
490 } |
492 } |
491 } else { |
493 } else { |
492 // draw total cargo tab |
494 /* draw total cargo tab */ |
493 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
495 DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
494 for (CargoID i = 0; i < NUM_CARGO; i++) { |
496 for (CargoID i = 0; i < NUM_CARGO; i++) { |
495 if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
497 if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
496 y += 14; |
498 y += 14; |
497 SetDParam(0, i); // {CARGO} #1 |
499 SetDParam(0, i); // {CARGO} #1 |