equal
deleted
inserted
replaced
63 return; |
63 return; |
64 |
64 |
65 // find a locomotive in the depot. |
65 // find a locomotive in the depot. |
66 found = NULL; |
66 found = NULL; |
67 FOR_ALL_VEHICLES(v) { |
67 FOR_ALL_VEHICLES(v) { |
68 if (v->type == VEH_Train && v->subtype==0 && |
68 if (v->type == VEH_Train && v->subtype == TS_Front_Engine && |
69 v->tile == tile && |
69 v->tile == tile && |
70 v->u.rail.track == 0x80) { |
70 v->u.rail.track == 0x80) { |
71 if (found != NULL) // must be exactly one. |
71 if (found != NULL) // must be exactly one. |
72 return; |
72 return; |
73 found = v; |
73 found = v; |
312 /* determine amount of items for scroller */ |
312 /* determine amount of items for scroller */ |
313 num = 0; |
313 num = 0; |
314 hnum = 1; |
314 hnum = 1; |
315 FOR_ALL_VEHICLES(v) { |
315 FOR_ALL_VEHICLES(v) { |
316 if (v->type == VEH_Train && |
316 if (v->type == VEH_Train && |
317 (v->subtype == 0 || v->subtype == 4) && |
317 (v->subtype == TS_Front_Engine || v->subtype == TS_Free_Car) && |
318 v->tile == (TileIndex)tile && |
318 v->tile == (TileIndex)tile && |
319 v->u.rail.track == 0x80) { |
319 v->u.rail.track == 0x80) { |
320 num++; |
320 num++; |
321 // determine number of items in the X direction. |
321 // determine number of items in the X direction. |
322 if (v->subtype == 0) { |
322 if (v->subtype == TS_Front_Engine) { |
323 i = 0; |
323 i = 0; |
324 u = v; |
324 u = v; |
325 do i++; while ( (u=u->next) != NULL); |
325 do i++; while ( (u=u->next) != NULL); |
326 if (i > hnum) hnum = i; |
326 if (i > hnum) hnum = i; |
327 } |
327 } |
347 num = w->vscroll.pos; |
347 num = w->vscroll.pos; |
348 |
348 |
349 // draw all trains |
349 // draw all trains |
350 FOR_ALL_VEHICLES(v) { |
350 FOR_ALL_VEHICLES(v) { |
351 if (v->type == VEH_Train && |
351 if (v->type == VEH_Train && |
352 v->subtype == 0 && |
352 v->subtype == TS_Front_Engine && |
353 v->tile == (TileIndex)tile && |
353 v->tile == (TileIndex)tile && |
354 v->u.rail.track == 0x80 && |
354 v->u.rail.track == 0x80 && |
355 --num < 0 && num >= -w->vscroll.cap) { |
355 --num < 0 && num >= -w->vscroll.cap) { |
356 |
356 |
357 DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel); |
357 DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel); |
375 } |
375 } |
376 |
376 |
377 // draw all remaining vehicles |
377 // draw all remaining vehicles |
378 FOR_ALL_VEHICLES(v) { |
378 FOR_ALL_VEHICLES(v) { |
379 if (v->type == VEH_Train && |
379 if (v->type == VEH_Train && |
380 v->subtype == 4 && |
380 v->subtype == TS_Free_Car && |
381 v->tile == (TileIndex)tile && |
381 v->tile == (TileIndex)tile && |
382 v->u.rail.track == 0x80 && |
382 v->u.rail.track == 0x80 && |
383 --num < 0 && num >= -w->vscroll.cap) { |
383 --num < 0 && num >= -w->vscroll.cap) { |
384 |
384 |
385 DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel); |
385 DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel); |
422 row += w->vscroll.pos; |
422 row += w->vscroll.pos; |
423 |
423 |
424 /* go through all the locomotives */ |
424 /* go through all the locomotives */ |
425 FOR_ALL_VEHICLES(v) { |
425 FOR_ALL_VEHICLES(v) { |
426 if (v->type == VEH_Train && |
426 if (v->type == VEH_Train && |
427 v->subtype == 0 && |
427 v->subtype == TS_Front_Engine && |
428 v->tile == w->window_number && |
428 v->tile == w->window_number && |
429 v->u.rail.track == 0x80 && |
429 v->u.rail.track == 0x80 && |
430 --row < 0) { |
430 --row < 0) { |
431 if (area_x >= 0) area_x += w->hscroll.pos; |
431 if (area_x >= 0) area_x += w->hscroll.pos; |
432 goto found_it; |
432 goto found_it; |
436 area_x--; /* free wagons don't have an initial loco. */ |
436 area_x--; /* free wagons don't have an initial loco. */ |
437 |
437 |
438 /* and then the list of free wagons */ |
438 /* and then the list of free wagons */ |
439 FOR_ALL_VEHICLES(v) { |
439 FOR_ALL_VEHICLES(v) { |
440 if (v->type == VEH_Train && |
440 if (v->type == VEH_Train && |
441 v->subtype == 4 && |
441 v->subtype == TS_Free_Car && |
442 v->tile == w->window_number && |
442 v->tile == w->window_number && |
443 v->u.rail.track == 0x80 && |
443 v->u.rail.track == 0x80 && |
444 --row < 0) |
444 --row < 0) |
445 goto found_it; |
445 goto found_it; |
446 } |
446 } |
453 |
453 |
454 found_it: |
454 found_it: |
455 d->head = d->wagon = v; |
455 d->head = d->wagon = v; |
456 |
456 |
457 /* either pressed the flag or the number, but only when it's a loco */ |
457 /* either pressed the flag or the number, but only when it's a loco */ |
458 if (area_x < 0 && v->subtype==0) |
458 if (area_x < 0 && v->subtype == TS_Front_Engine) |
459 return area_x; |
459 return area_x; |
460 |
460 |
461 /* find the vehicle in this row that was clicked */ |
461 /* find the vehicle in this row that was clicked */ |
462 while (--area_x >= 0) { |
462 while (--area_x >= 0) { |
463 v = v->next; |
463 v = v->next; |
473 { |
473 { |
474 Vehicle *v; |
474 Vehicle *v; |
475 |
475 |
476 v = GetVehicle(sel); |
476 v = GetVehicle(sel); |
477 |
477 |
478 if (/*v->subtype == 0 ||*/ v == wagon) |
478 if (/*v->subtype == TS_Front_Engine ||*/ v == wagon) |
479 return; |
479 return; |
480 |
480 |
481 if (wagon == NULL) { |
481 if (wagon == NULL) { |
482 if (head != NULL) |
482 if (head != NULL) |
483 wagon = GetLastVehicleInChain(head); |
483 wagon = GetLastVehicleInChain(head); |
574 |
574 |
575 HandleButtonClick(w, e->click.widget); |
575 HandleButtonClick(w, e->click.widget); |
576 |
576 |
577 sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; |
577 sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0; |
578 |
578 |
579 if (v->subtype != 0) { |
579 if (v->subtype != TS_Front_Engine) { |
580 DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); |
580 DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)); |
581 } else { |
581 } else { |
582 _backup_orders_tile = v->tile; |
582 _backup_orders_tile = v->tile; |
583 BackupVehicleOrders(v, _backup_orders_data); |
583 BackupVehicleOrders(v, _backup_orders_data); |
584 if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE))) |
584 if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE))) |
595 |
595 |
596 if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && |
596 if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 && |
597 sel != INVALID_VEHICLE) { |
597 sel != INVALID_VEHICLE) { |
598 if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
598 if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
599 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
599 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
600 } else if (gdvp.head != NULL && gdvp.head->subtype==0) { |
600 } else if (gdvp.head != NULL && gdvp.head->subtype == TS_Front_Engine) { |
601 ShowTrainViewWindow(gdvp.head); |
601 ShowTrainViewWindow(gdvp.head); |
602 } |
602 } |
603 } |
603 } |
604 } break; |
604 } break; |
605 |
605 |
1363 |
1363 |
1364 if (id_v >= vl->list_length) return; // click out of list bound |
1364 if (id_v >= vl->list_length) return; // click out of list bound |
1365 |
1365 |
1366 v = GetVehicle(vl->sort_list[id_v].index); |
1366 v = GetVehicle(vl->sort_list[id_v].index); |
1367 |
1367 |
1368 assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner); |
1368 assert(v->type == VEH_Train && v->subtype == TS_Front_Engine && v->owner == owner); |
1369 |
1369 |
1370 ShowTrainViewWindow(v); |
1370 ShowTrainViewWindow(v); |
1371 } |
1371 } |
1372 } break; |
1372 } break; |
1373 |
1373 |