Files @ r4381:c965d1f3016a
Branch filter:

Location: cpp/openttd-patchpack/source/train_gui.c - annotation

belugas
(svn r6131) -Codechange : Complete all missing _ttdpatch_flags entries
-Feature : both unifiedmaglevmode are now set.
Maglev and monorail are not allowed to run on each other tracks and will not be.
Setting those flags will allow grfsets as the Norvegian one to be loaded
-Codechange : link the TTDPatch's irregularstations with OTTD's nonuniform_stations
-Codechange : Reformat the whole array (thanks Rubidium, it sure looks better now)
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
r2186:5ee653b1b5e1
r2186:5ee653b1b5e1
r0:d63b455452f6
r1891:c5c5466afa35
r1299:07d5483b3f76
r2163:ae001e2aa5b0
r4041:22c02258c9b7
r1922:d5634e2fe7b3
r507:b1b0a0a3c313
r679:3a7b08cc8504
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r588:c0748f0d2104
r1313:da473558c9d7
r2676:cfc81c07cc6a
r2962:16f2ef02fde1
r4261:8c2d0c75e37a
r420:d99a908fcdb7
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r842:96908cec3367
r4171:bf306290d87e
r842:96908cec3367
r842:96908cec3367
r4288:b6dbdc0a7329
r842:96908cec3367
r1907:da80804490bd
r842:96908cec3367
r842:96908cec3367
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r3477:aa44670525a9
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r1907:da80804490bd
r2840:09966d5ba228
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1908:8c22d41a448a
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r2084:845406eb98cd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r1907:da80804490bd
r4293:cbb984a32af5
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r3651:5f0e6bc9275f
r3651:5f0e6bc9275f
r3651:5f0e6bc9275f
r3651:5f0e6bc9275f
r842:96908cec3367
r842:96908cec3367
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r842:96908cec3367
r842:96908cec3367
r3393:9d958dc7a778
r867:c270355a1b34
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r1907:da80804490bd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r3685:4cab4e77bdcd
r1907:da80804490bd
r1907:da80804490bd
r2443:6fdc13cc4fbe
r2443:6fdc13cc4fbe
r2456:aad40f8d9c89
r3477:aa44670525a9
r2443:6fdc13cc4fbe
r2443:6fdc13cc4fbe
r2443:6fdc13cc4fbe
r3651:5f0e6bc9275f
r3651:5f0e6bc9275f
r3651:5f0e6bc9275f
r842:96908cec3367
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2676:cfc81c07cc6a
r0:d63b455452f6
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3948:4c986a48e294
r588:c0748f0d2104
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r2639:e298192a7c03
r193:6aa65dc5a4b4
r3948:4c986a48e294
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3887:731a50a79f3b
r2244:0a45bb36cb48
r3948:4c986a48e294
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r524:21cbb8d1771d
r4171:bf306290d87e
r524:21cbb8d1771d
r2971:ce60b5a9ca01
r524:21cbb8d1771d
r2971:ce60b5a9ca01
r2971:ce60b5a9ca01
r1926:ff7c3132a421
r539:6383330746de
r524:21cbb8d1771d
r3355:881cb92af87e
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r4077:259c4c4aacad
r524:21cbb8d1771d
r867:c270355a1b34
r867:c270355a1b34
r3040:17d18b4d8a75
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r0:d63b455452f6
r193:6aa65dc5a4b4
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2520:1767662fb229
r2477:1fce8206d479
r460:c4c0c048eb73
r460:c4c0c048eb73
r1926:ff7c3132a421
r4077:259c4c4aacad
r4077:259c4c4aacad
r0:d63b455452f6
r4077:259c4c4aacad
r460:c4c0c048eb73
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r2520:1767662fb229
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2498:8dfa040ed505
r0:d63b455452f6
r460:c4c0c048eb73
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r524:21cbb8d1771d
r867:c270355a1b34
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2498:8dfa040ed505
r539:6383330746de
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1907:da80804490bd
r0:d63b455452f6
r0:d63b455452f6
r1907:da80804490bd
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2498:8dfa040ed505
r2498:8dfa040ed505
r540:14f3c0eda6cb
r0:d63b455452f6
r968:cc00c557f4bf
r2498:8dfa040ed505
r2498:8dfa040ed505
r968:cc00c557f4bf
r968:cc00c557f4bf
r4299:ee21d1b71ef0
r968:cc00c557f4bf
r968:cc00c557f4bf
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r0:d63b455452f6
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r176:7d9100f64c27
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1908:8c22d41a448a
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r4000:702cb45b8eab
r193:6aa65dc5a4b4
r0:d63b455452f6
r1901:e806afa50723
r3242:4dca345fd1dd
r0:d63b455452f6
r0:d63b455452f6
r2147:d338acdbdc70
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2593:575b757911eb
r2593:575b757911eb
r2593:575b757911eb
r2593:575b757911eb
r2593:575b757911eb
r2593:575b757911eb
r3845:e0b12600a260
r2593:575b757911eb
r2593:575b757911eb
r1790:aafbb2ff1ae7
r0:d63b455452f6
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r3919:4c67b41f0b48
r4049:81f2dc20439f
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r1922:d5634e2fe7b3
r0:d63b455452f6
r3919:4c67b41f0b48
r1922:d5634e2fe7b3
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3049:fe328ef6dad7
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r1922:d5634e2fe7b3
r0:d63b455452f6
r3919:4c67b41f0b48
r0:d63b455452f6
r2593:575b757911eb
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r4049:81f2dc20439f
r3919:4c67b41f0b48
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r1313:da473558c9d7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1901:e806afa50723
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r2593:575b757911eb
r0:d63b455452f6
r0:d63b455452f6
r4077:259c4c4aacad
r1986:40fe0be5bb1e
r0:d63b455452f6
r1986:40fe0be5bb1e
r1986:40fe0be5bb1e
r2676:cfc81c07cc6a
r2593:575b757911eb
r1986:40fe0be5bb1e
r0:d63b455452f6
r0:d63b455452f6
r914:d035c73a9648
r914:d035c73a9648
r914:d035c73a9648
r914:d035c73a9648
r0:d63b455452f6
r3919:4c67b41f0b48
r193:6aa65dc5a4b4
r0:d63b455452f6
r1313:da473558c9d7
r1313:da473558c9d7
r0:d63b455452f6
r1313:da473558c9d7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2676:cfc81c07cc6a
r1986:40fe0be5bb1e
r867:c270355a1b34
r3919:4c67b41f0b48
r22:d13b1ad89539
r534:46e9db8de483
r0:d63b455452f6
r1019:90da3857ff29
r2593:575b757911eb
r2593:575b757911eb
r2113:600d6ea0d897
r1019:90da3857ff29
r22:d13b1ad89539
r2517:f67017080a5a
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2676:cfc81c07cc6a
r1986:40fe0be5bb1e
r867:c270355a1b34
r3919:4c67b41f0b48
r0:d63b455452f6
r1019:90da3857ff29
r1002:5d06b791cb48
r1002:5d06b791cb48
r1002:5d06b791cb48
r1002:5d06b791cb48
r1002:5d06b791cb48
r2113:600d6ea0d897
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2436:963efe8b84cc
r0:d63b455452f6
r0:d63b455452f6
r1922:d5634e2fe7b3
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2951:a52cbb930051
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2676:cfc81c07cc6a
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2951:a52cbb930051
r2951:a52cbb930051
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3845:e0b12600a260
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2676:cfc81c07cc6a
r0:d63b455452f6
r0:d63b455452f6
r2951:a52cbb930051
r2951:a52cbb930051
r2951:a52cbb930051
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2951:a52cbb930051
r1922:d5634e2fe7b3
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r193:6aa65dc5a4b4
r0:d63b455452f6
r3919:4c67b41f0b48
r0:d63b455452f6
r2602:e9a03af71c79
r2676:cfc81c07cc6a
r2602:e9a03af71c79
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2484:d3b91bb07536
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r919:57ef81f1ba8e
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r2484:d3b91bb07536
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2484:d3b91bb07536
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r10:6cb1c9bf87be
r10:6cb1c9bf87be
r4077:259c4c4aacad
r4077:259c4c4aacad
r4077:259c4c4aacad
r4077:259c4c4aacad
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r2484:d3b91bb07536
r2484:d3b91bb07536
r2484:d3b91bb07536
r2484:d3b91bb07536
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3157:d2dcc469a38b
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2484:d3b91bb07536
r0:d63b455452f6
r10:6cb1c9bf87be
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r10:6cb1c9bf87be
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4171:bf306290d87e
r2244:0a45bb36cb48
r2561:bff0d1890738
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2676:cfc81c07cc6a
r2244:0a45bb36cb48
r2561:bff0d1890738
r2676:cfc81c07cc6a
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2561:bff0d1890738
r2561:bff0d1890738
r2561:bff0d1890738
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4171:bf306290d87e
r2244:0a45bb36cb48
r4171:bf306290d87e
r2244:0a45bb36cb48
r2561:bff0d1890738
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r867:c270355a1b34
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r982:ae84d4003591
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4077:259c4c4aacad
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4077:259c4c4aacad
r4077:259c4c4aacad
r4077:259c4c4aacad
r4077:259c4c4aacad
r4077:259c4c4aacad
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4077:259c4c4aacad
r2261:e6fb9fd7ed61
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4171:bf306290d87e
r2561:bff0d1890738
r2561:bff0d1890738
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2561:bff0d1890738
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r982:ae84d4003591
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r919:57ef81f1ba8e
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r982:ae84d4003591
r0:d63b455452f6
r2676:cfc81c07cc6a
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r982:ae84d4003591
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r3256:8bd6c6277040
r3256:8bd6c6277040
r3256:8bd6c6277040
r0:d63b455452f6
r2676:cfc81c07cc6a
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r3919:4c67b41f0b48
r982:ae84d4003591
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r982:ae84d4003591
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r0:d63b455452f6
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r2244:0a45bb36cb48
r4344:bff007ae1fd1
r176:7d9100f64c27
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1002:5d06b791cb48
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1901:e806afa50723
r0:d63b455452f6
r3919:4c67b41f0b48
r3919:4c67b41f0b48
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1802:acc0f0bda113
r0:d63b455452f6
r1802:acc0f0bda113
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1802:acc0f0bda113
r1802:acc0f0bda113
r382:c78a7dbc2e04
r1802:acc0f0bda113
r3491:10ed78e15d31
r1802:acc0f0bda113
r534:46e9db8de483
r2084:845406eb98cd
r3008:545425696ea0
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1802:acc0f0bda113
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1802:acc0f0bda113
r1802:acc0f0bda113
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4345:3e958e22413f
r4345:3e958e22413f
r4345:3e958e22413f
r4345:3e958e22413f
r4345:3e958e22413f
r4345:3e958e22413f
r176:7d9100f64c27
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2275:5b6aa087e1e2
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r1485:a9e66a254466
r0:d63b455452f6
r0:d63b455452f6
r4171:bf306290d87e
r2561:bff0d1890738
r0:d63b455452f6
r0:d63b455452f6
r1802:acc0f0bda113
r0:d63b455452f6
r1802:acc0f0bda113
r0:d63b455452f6
r0:d63b455452f6
r919:57ef81f1ba8e
r193:6aa65dc5a4b4
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r193:6aa65dc5a4b4
r2867:03d72c58b3ea
r1387:87d700a7ee55
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r3393:9d958dc7a778
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r2867:03d72c58b3ea
r1387:87d700a7ee55
r1387:87d700a7ee55
r1387:87d700a7ee55
r0:d63b455452f6
r534:46e9db8de483
r2261:e6fb9fd7ed61
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4251:8615bb529756
r4251:8615bb529756
r4251:8615bb529756
r4251:8615bb529756
r4251:8615bb529756
r0:d63b455452f6
r3477:aa44670525a9
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r555:cefc6ad212ed
r0:d63b455452f6
r0:d63b455452f6
r555:cefc6ad212ed
r3477:aa44670525a9
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1313:da473558c9d7
r534:46e9db8de483
r0:d63b455452f6
r3477:aa44670525a9
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r395:9c19f4df13fc
r555:cefc6ad212ed
r395:9c19f4df13fc
r3477:aa44670525a9
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3477:aa44670525a9
r4077:259c4c4aacad
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2103:d4b2ab6a0279
r2517:f67017080a5a
r2113:600d6ea0d897
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r919:57ef81f1ba8e
r0:d63b455452f6
r2952:e97f823d2dbe
r755:02ea8c27f87d
r193:6aa65dc5a4b4
r0:d63b455452f6
r755:02ea8c27f87d
r0:d63b455452f6
r0:d63b455452f6
r755:02ea8c27f87d
r601:44f11989d19e
r601:44f11989d19e
r0:d63b455452f6
r755:02ea8c27f87d
r193:6aa65dc5a4b4
r0:d63b455452f6
r755:02ea8c27f87d
r193:6aa65dc5a4b4
r0:d63b455452f6
r755:02ea8c27f87d
r0:d63b455452f6
r0:d63b455452f6
r755:02ea8c27f87d
r0:d63b455452f6
r0:d63b455452f6
r755:02ea8c27f87d
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1485:a9e66a254466
r1485:a9e66a254466
r1485:a9e66a254466
r1485:a9e66a254466
r1485:a9e66a254466
r1485:a9e66a254466
r1485:a9e66a254466
r0:d63b455452f6
r338:3990dde2fc4f
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2244:0a45bb36cb48
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1485:a9e66a254466
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r2561:bff0d1890738
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r540:14f3c0eda6cb
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r4329:7372b441f7d8
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r0:d63b455452f6
r2084:845406eb98cd
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r919:57ef81f1ba8e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2602:e9a03af71c79
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r156:dd00481b3251
r156:dd00481b3251
r156:dd00481b3251
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r193:6aa65dc5a4b4
r0:d63b455452f6
r193:6aa65dc5a4b4
r2252:82a854ab03b0
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r3477:aa44670525a9
r534:46e9db8de483
r534:46e9db8de483
r3401:4b5dcf559b96
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r2822:5fd54c42ddc7
r2952:e97f823d2dbe
r2959:9dd09fc8fb13
r2602:e9a03af71c79
r2602:e9a03af71c79
r2602:e9a03af71c79
r3844:fefde6f58157
r3844:fefde6f58157
r2602:e9a03af71c79
r2602:e9a03af71c79
r2676:cfc81c07cc6a
r2602:e9a03af71c79
r0:d63b455452f6
r0:d63b455452f6
r2602:e9a03af71c79
r0:d63b455452f6
r0:d63b455452f6
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r0:d63b455452f6
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r534:46e9db8de483
r534:46e9db8de483
r534:46e9db8de483
r534:46e9db8de483
r2822:5fd54c42ddc7
r0:d63b455452f6
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1790:aafbb2ff1ae7
r1790:aafbb2ff1ae7
r0:d63b455452f6
r919:57ef81f1ba8e
r534:46e9db8de483
r4299:ee21d1b71ef0
r0:d63b455452f6
r0:d63b455452f6
r156:dd00481b3251
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r156:dd00481b3251
r0:d63b455452f6
r919:57ef81f1ba8e
r156:dd00481b3251
r1790:aafbb2ff1ae7
r1790:aafbb2ff1ae7
r193:6aa65dc5a4b4
r2819:50c046aedc63
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2548:9570bbbdacab
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r1820:335b057adac7
r2548:9570bbbdacab
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r4077:259c4c4aacad
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r176:7d9100f64c27
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4171:bf306290d87e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r2959:9dd09fc8fb13
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r588:c0748f0d2104
r588:c0748f0d2104
r164:32c72e637930
r867:c270355a1b34
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r588:c0748f0d2104
r588:c0748f0d2104
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2466:6653b19c6415
r2466:6653b19c6415
r588:c0748f0d2104
r588:c0748f0d2104
r2952:e97f823d2dbe
r164:32c72e637930
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r243:ca7c3d233c70
r588:c0748f0d2104
r588:c0748f0d2104
r0:d63b455452f6
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r4077:259c4c4aacad
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r1962:cc4c06e3f6b5
r2466:6653b19c6415
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r867:c270355a1b34
r588:c0748f0d2104
r588:c0748f0d2104
r1294:8792ed412267
r588:c0748f0d2104
r867:c270355a1b34
r588:c0748f0d2104
r0:d63b455452f6
r0:d63b455452f6
r168:a71deedc43fb
r588:c0748f0d2104
r588:c0748f0d2104
r2406:ca53e91ceee1
r0:d63b455452f6
r588:c0748f0d2104
r588:c0748f0d2104
r4266:5d7162f0a3b0
r588:c0748f0d2104
r164:32c72e637930
r588:c0748f0d2104
r164:32c72e637930
r2570:9c32c3acd198
r588:c0748f0d2104
r0:d63b455452f6
r588:c0748f0d2104
r4077:259c4c4aacad
r588:c0748f0d2104
r4077:259c4c4aacad
r588:c0748f0d2104
r4077:259c4c4aacad
r588:c0748f0d2104
r193:6aa65dc5a4b4
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r164:32c72e637930
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r0:d63b455452f6
r588:c0748f0d2104
r588:c0748f0d2104
r0:d63b455452f6
r588:c0748f0d2104
r588:c0748f0d2104
r0:d63b455452f6
r0:d63b455452f6
r2952:e97f823d2dbe
r757:d408dd9b02c7
r588:c0748f0d2104
r588:c0748f0d2104
r1246:1fc4189e63a6
r164:32c72e637930
r164:32c72e637930
r588:c0748f0d2104
r757:d408dd9b02c7
r842:96908cec3367
r164:32c72e637930
r588:c0748f0d2104
r757:d408dd9b02c7
r174:cd15d16e1367
r4171:bf306290d87e
r193:6aa65dc5a4b4
r2549:1549d4b2ba28
r0:d63b455452f6
r164:32c72e637930
r0:d63b455452f6
r4077:259c4c4aacad
r0:d63b455452f6
r4266:5d7162f0a3b0
r164:32c72e637930
r4077:259c4c4aacad
r164:32c72e637930
r4077:259c4c4aacad
r0:d63b455452f6
r0:d63b455452f6
r3884:d1a761c29795
r3884:d1a761c29795
r3884:d1a761c29795
r3884:d1a761c29795
r867:c270355a1b34
r4077:259c4c4aacad
r4088:833d4101efeb
r842:96908cec3367
r842:96908cec3367
r842:96908cec3367
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r164:32c72e637930
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r1246:1fc4189e63a6
r164:32c72e637930
r588:c0748f0d2104
r4077:259c4c4aacad
r588:c0748f0d2104
r164:32c72e637930
r164:32c72e637930
r588:c0748f0d2104
r164:32c72e637930
r588:c0748f0d2104
r1246:1fc4189e63a6
r1246:1fc4189e63a6
r588:c0748f0d2104
r164:32c72e637930
r588:c0748f0d2104
r767:6078c5b2d80f
r4280:14fc9691f5d4
r767:6078c5b2d80f
r767:6078c5b2d80f
r164:32c72e637930
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r588:c0748f0d2104
r164:32c72e637930
r164:32c72e637930
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r3919:4c67b41f0b48
r867:c270355a1b34
r867:c270355a1b34
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r164:32c72e637930
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2466:6653b19c6415
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r164:32c72e637930
r588:c0748f0d2104
r164:32c72e637930
r588:c0748f0d2104
r0:d63b455452f6
r4077:259c4c4aacad
r1402:4095ff43e843
r3919:4c67b41f0b48
r164:32c72e637930
r867:c270355a1b34
r867:c270355a1b34
r3919:4c67b41f0b48
r867:c270355a1b34
r0:d63b455452f6
r0:d63b455452f6
/* $Id$ */

#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "functions.h"
#include "rail_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "map.h"
#include "window.h"
#include "gui.h"
#include "gfx.h"
#include "vehicle.h"
#include "viewport.h"
#include "station.h"
#include "command.h"
#include "player.h"
#include "engine.h"
#include "vehicle_gui.h"
#include "depot.h"
#include "train.h"
#include "newgrf_engine.h"
#include "date.h"

/**
 * Draw the purchase info details of train engine at a given location.
 * @param x,y location where to draw the info
 * @param engine_number the engine of which to draw the info of
 */
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
{
	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
	const Engine *e = GetEngine(engine_number);
	int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
	YearMonthDay ymd;
	ConvertDateToYMD(e->intro_date, &ymd);

	/* Purchase Cost - Engine weight */
	SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);
	SetDParam(1, rvi->weight << multihead);
	DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0);
	y += 10;

	/* Max speed - Engine power */
	SetDParam(0, rvi->max_speed);
	SetDParam(1, rvi->power << multihead);
	DrawString(x,y, STR_PURCHASE_INFO_SPEED_POWER, 0);
	y += 10;

	/* Running cost */
	SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
	DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
	y += 10;

	/* Powered wagons power - Powered wagons extra weight */
	if (rvi->pow_wag_power != 0) {
		SetDParam(0, rvi->pow_wag_power);
		SetDParam(1, rvi->pow_wag_weight);
		DrawString(x,y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT, 0);
		y += 10;
	};

	/* Cargo type + capacity, or N/A */
	SetDParam(0, STR_8838_N_A);
	SetDParam(2, STR_EMPTY);
	if (rvi->capacity != 0) {
		SetDParam(0, _cargoc.names_long[rvi->cargo_type]);
		SetDParam(1, rvi->capacity << multihead);
		SetDParam(2, STR_9842_REFITTABLE);
	}
	DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0);
	y += 10;

	/* Design date - Life length */
	SetDParam(0, ymd.year);
	SetDParam(1, e->lifelength);
	DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
	y += 10;

	/* Reliability */
	SetDParam(0, e->reliability * 100 >> 16);
	DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
	y += 10;

	/* Additional text from NewGRF */
	// XXX 227 will become a calculated width...
	y += ShowAdditionalText(x, y, 227, engine_number);
}

/**
 * Draw the purchase info details of a train wagon at a given location.
 * @param x,y location where to draw the info
 * @param engine_number the engine of which to draw the info of
 */
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number)
{
	const RailVehicleInfo *rvi = RailVehInfo(engine_number);
	bool refittable = (EngInfo(engine_number)->refit_mask != 0);

	/* Purchase cost */
	SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8);
	DrawString(x, y, STR_PURCHASE_INFO_COST, 0);
	y += 10;

	/* Wagon weight - (including cargo) */
	SetDParam(0, rvi->weight);
	SetDParam(1, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight);
	DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0);
	y += 10;

	/* Cargo type + capacity, or N/A */
	SetDParam(0, STR_8838_N_A);
	SetDParam(2, STR_EMPTY);
	if (rvi->capacity != 0) {
		SetDParam(0, _cargoc.names_long[rvi->cargo_type]);
		SetDParam(1, rvi->capacity);
		SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
	}
	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
	y += 10;

	/* Wagon speed limit, displayed if above zero */
	if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
		SetDParam(0, rvi->max_speed);
		DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0);
		y += 10;
	}

	/* Additional text from NewGRF */
	y += ShowAdditionalText(x, y, 227, engine_number);
}

void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
	Vehicle *v, *found;

	if (!success) return;

	// find a locomotive in the depot.
	found = NULL;
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train && IsFrontEngine(v) &&
				v->tile == tile &&
				v->u.rail.track == 0x80) {
			if (found != NULL) return; // must be exactly one.
			found = v;
		}
	}

	// if we found a loco,
	if (found != NULL) {
		found = GetLastVehicleInChain(found);
		// put the new wagon at the end of the loco.
		DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
		RebuildVehicleLists();
	}
}

void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
	const Vehicle *v;

	if (!success) return;

	v = GetVehicle(_new_vehicle_id);
	if (tile == _backup_orders_tile) {
		_backup_orders_tile = 0;
		RestoreVehicleOrders(v, _backup_orders_data);
	}
	ShowTrainViewWindow(v);
}

void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
	if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id));
}

static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
	EngineID *selected_id, RailType railtype, byte show_max, bool is_engine)
{
	EngineID j;

	for (j = 0; j < NUM_TRAIN_ENGINES; j++) {
		EngineID i = GetRailVehAtPosition(j);
		const Engine *e = GetEngine(i);
		const RailVehicleInfo *rvi = RailVehInfo(i);

		if (!HasPowerOnRail(e->railtype, railtype) || !(rvi->flags & RVI_WAGON) != is_engine ||
				!HASBIT(e->player_avail, _local_player))
			continue;

		if (*sel == 0) *selected_id = i;

		if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
			DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);
			DrawTrainEngine(*x + 29, *y + 6, i, GetEnginePalette(i, _local_player));
			*y += 14;
		}
		--*sel;
	}
}

static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
{
	switch (e->event) {
	case WE_PAINT:

		if (w->window_number == 0) SETBIT(w->disabled_state, 5);

		{
			int count = 0;
			RailType railtype = WP(w,buildtrain_d).railtype;
			EngineID i;

			for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
				const Engine *e = GetEngine(i);
				if (HasPowerOnRail(e->railtype, railtype) &&
						HASBIT(e->player_avail, _local_player)) {
					count++;
				}
			}
			SetVScrollCount(w, count);
		}

		SetDParam(0, WP(w,buildtrain_d).railtype + STR_881C_NEW_RAIL_VEHICLES);
		DrawWindowWidgets(w);

		{
			RailType railtype = WP(w,buildtrain_d).railtype;
			int sel = WP(w,buildtrain_d).sel_index;
			int pos = w->vscroll.pos;
			int x = 1;
			int y = 15;
			EngineID selected_id = INVALID_ENGINE;

			/* Ensure that custom engines which substituted wagons
			 * are sorted correctly.
			 * XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as
			 * engines to get more types.. Stays here until we have our own format
			 * then it is exit!!! */
			engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, true); // True engines
			engine_drawing_loop(&x, &y, &pos, &sel, &selected_id, railtype, w->vscroll.cap, false); // Feeble wagons

			WP(w,buildtrain_d).sel_engine = selected_id;

			if (selected_id != INVALID_ENGINE) {
				const RailVehicleInfo *rvi = RailVehInfo(selected_id);

				if (!(rvi->flags & RVI_WAGON)) {
					/* it's an engine */
					DrawTrainEnginePurchaseInfo(2, w->widget[4].top + 1,selected_id);
				} else {
					/* it's a wagon */
					DrawTrainWagonPurchaseInfo(2, w->widget[4].top + 1, selected_id);
				}
			}
		}
	break;

	case WE_CLICK: {
		switch (e->click.widget) {
		case 2: {
			uint i = (e->click.pt.y - 14) / 14;
			if (i < w->vscroll.cap) {
				WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;
				SetWindowDirty(w);
			}
		} break;
		case 5: {
			EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
			if (sel_eng != INVALID_ENGINE)
				DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
		}	break;
		case 6: { /* rename */
			EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
			if (sel_eng != INVALID_ENGINE) {
				WP(w,buildtrain_d).rename_engine = sel_eng;
				ShowQueryString(GetCustomEngineName(sel_eng),
					STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL);
			}
		} break;
		}
	} break;

	case WE_ON_EDIT_TEXT: {
		if (e->edittext.str[0] != '\0') {
			_cmd_text = e->edittext.str;
			DoCommandP(0, WP(w,buildtrain_d).rename_engine, 0, NULL,
				CMD_RENAME_ENGINE | CMD_MSG(STR_886B_CAN_T_RENAME_TRAIN_VEHICLE));
		}
	} break;

	case WE_RESIZE: {
		if (e->sizing.diff.y == 0)
			break;

		w->vscroll.cap += e->sizing.diff.y / 14;
		w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
	} break;
	}
}

static const Widget _new_rail_vehicle_widgets[] = {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,               STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   227,     0,    13, STR_JUST_STRING,        STR_018C_WINDOW_TITLE_DRAG_THIS},
{     WWT_MATRIX, RESIZE_BOTTOM,    14,     0,   215,    14,   125, 0x801,                  STR_8843_TRAIN_VEHICLE_SELECTION},
{  WWT_SCROLLBAR, RESIZE_BOTTOM,    14,   216,   227,    14,   125, 0x0,                    STR_0190_SCROLL_BAR_SCROLLS_LIST},
{      WWT_PANEL,     RESIZE_TB,    14,     0,   227,   126,   197, 0x0,                    STR_NULL},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   107,   198,   209, STR_881F_BUILD_VEHICLE, STR_8844_BUILD_THE_HIGHLIGHTED_TRAIN},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   108,   215,   198,   209, STR_8820_RENAME,        STR_8845_RENAME_TRAIN_VEHICLE_TYPE},
{  WWT_RESIZEBOX,     RESIZE_TB,    14,   216,   227,   198,   209, 0x0,                    STR_RESIZE_BUTTON},
{   WIDGETS_END},
};

static const WindowDesc _new_rail_vehicle_desc = {
	-1, -1, 228, 210,
	WC_BUILD_VEHICLE,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
	_new_rail_vehicle_widgets,
	NewRailVehicleWndProc
};

static void ShowBuildTrainWindow(TileIndex tile)
{
	Window *w;

	DeleteWindowById(WC_BUILD_VEHICLE, tile);

	w = AllocateWindowDesc(&_new_rail_vehicle_desc);
	w->window_number = tile;
	w->vscroll.cap = 8;
	w->widget[2].unkA = (w->vscroll.cap << 8) + 1;

	w->resize.step_height = 14;
	w->resize.height = w->height - 14 * 4; // Minimum of 4 vehicles in the display

	if (tile != 0) {
		w->caption_color = GetTileOwner(tile);
		WP(w,buildtrain_d).railtype = GetRailType(tile);
	} else {
		w->caption_color = _local_player;
		WP(w,buildtrain_d).railtype = GetBestRailtype(GetPlayer(_local_player));
	}
}

/**
 * Get the number of pixels for the given wagon length.
 * @param len Length measured in 1/8ths of a standard wagon.
 * @return Number of pixels across.
 */
static int WagonLengthToPixels(int len) {
	return (len * _traininfo_vehicle_width) / 8;
}

static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
{
	DrawPixelInfo tmp_dpi, *old_dpi;
	int dx = -(skip * 8) / _traininfo_vehicle_width;
	/* Position of highlight box */
	int highlight_l = 0;
	int highlight_r = 0;

	if (!FillDrawPixelInfo(&tmp_dpi, NULL, x - 2, y - 1, count + 1, 14)) return;

	count = (count * 8) / _traininfo_vehicle_width;

	old_dpi = _cur_dpi;
	_cur_dpi = &tmp_dpi;

	do {
		int width = v->u.rail.cached_veh_length;

		if (dx + width > 0) {
			if (dx <= count) {
				PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
				DrawSprite(GetTrainImage(v, DIR_W) | pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
				if (v->index == selection) {
					/* Set the highlight position */
					highlight_l = WagonLengthToPixels(dx) + 1;
					highlight_r = WagonLengthToPixels(dx + width) + 1;
				}
			}
		}
		dx += width;

		v = v->next;
	} while (dx < count && v != NULL);

	if (highlight_l != highlight_r) {
		/* Draw the highlight. Now done after drawing all the engines, as
		 * the next engine after the highlight could overlap it. */
		DrawFrameRect(highlight_l, 0, highlight_r, 13, 15, FR_BORDERONLY);
	}

	_cur_dpi = old_dpi;
}

static void DrawTrainDepotWindow(Window *w)
{
	TileIndex tile;
	Vehicle *v, *u;
	int num,x,y,i, hnum;
	Depot *depot;

	tile = w->window_number;

	/* setup disabled buttons */
	w->disabled_state =
		IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 5) | (1 << 8) | (1<<9));

	/* determine amount of items for scroller */
	num = 0;
	hnum = 8;
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train &&
				(IsFrontEngine(v) || IsFreeWagon(v)) &&
				v->tile == tile &&
				v->u.rail.track == 0x80) {
			num++;
			// determine number of items in the X direction.
			if (IsFrontEngine(v)) {
				hnum = max(hnum, v->u.rail.cached_total_length);
			}
		}
	}

	/* Always have 1 empty row, so people can change the setting of the train */
	num++;

	SetVScrollCount(w, num);
	SetHScrollCount(w, WagonLengthToPixels(hnum));

	/* locate the depot struct */
	depot = GetDepotByTile(tile);
	assert(depot != NULL);

	SetDParam(0, depot->town_index);
	DrawWindowWidgets(w);

	x = 2;
	y = 15;
	num = w->vscroll.pos;

	// draw all trains
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train && IsFrontEngine(v) &&
				v->tile == tile && v->u.rail.track == 0x80 &&
				--num < 0 && num >= -w->vscroll.cap) {
			DrawTrainImage(v, x+21, y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,traindepot_d).sel);
			/* Draw the train number */
			SetDParam(0, v->unitnumber);
			DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0);

			// Number of wagons relative to a standard length wagon (rounded up)
			SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
			DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0);	//Draw the counter

			/* Draw the pretty flag */
			DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + 15, y);

			y += 14;
		}
	}

	// draw all remaining vehicles
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train && IsFreeWagon(v) &&
				v->tile == tile && v->u.rail.track == 0x80 &&
				--num < 0 && num >= -w->vscroll.cap) {
			DrawTrainImage(v, x+50, y, w->hscroll.cap - 29, 0, WP(w,traindepot_d).sel);
			DrawString(x, y+2, STR_8816, 0);

			/*Draw the train counter */
			i = 0;
			u = v;
			do i++; while ( (u=u->next) != NULL);		//Determine length of train
			SetDParam(0, i);				//Set the counter
			DrawStringRightAligned(w->widget[6].right - 1, y + 4, STR_TINY_BLACK, 0);	//Draw the counter
			y += 14;
		}
	}
}

typedef struct GetDepotVehiclePtData {
	Vehicle *head;
	Vehicle *wagon;
} GetDepotVehiclePtData;

static int GetVehicleFromTrainDepotWndPt(const Window *w, int x, int y, GetDepotVehiclePtData *d)
{
	int row;
	int skip = 0;
	Vehicle *v;

	x = x - 23;

	row = (y - 14) / 14;
	if ((uint)row >= w->vscroll.cap) return 1; /* means err */

	row += w->vscroll.pos;

	/* go through all the locomotives */
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train &&
				IsFrontEngine(v) &&
				v->tile == w->window_number &&
				v->u.rail.track == 0x80 &&
				--row < 0) {
			skip = w->hscroll.pos;
			goto found_it;
		}
	}

	x -= _traininfo_vehicle_width; /* free wagons don't have an initial loco. */

	/* and then the list of free wagons */
	FOR_ALL_VEHICLES(v) {
		if (v->type == VEH_Train &&
				IsFreeWagon(v) &&
				v->tile == w->window_number &&
				v->u.rail.track == 0x80 &&
				--row < 0) {
			goto found_it;
		}
	}

	d->head = NULL;
	d->wagon = NULL;

	/* didn't find anything, get out */
	return 0;

found_it:
	d->head = d->wagon = v;

	/* either pressed the flag or the number, but only when it's a loco */
	if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? -2 : -1;

	skip = (skip * 8) / _traininfo_vehicle_width;
	x = (x * 8) / _traininfo_vehicle_width;

	/* Skip vehicles that are scrolled off the list */
	x += skip;

	/* find the vehicle in this row that was clicked */
	while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->next;

	// if an articulated part was selected, find its parent
	while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);

	d->wagon = v;

	return 0;
}

static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
{
	Vehicle *v;

	v = GetVehicle(sel);

	if (v == wagon) return;

	if (wagon == NULL) {
		if (head != NULL) wagon = GetLastVehicleInChain(head);
	} else  {
		wagon = GetPrevVehicleInChain(wagon);
		if (wagon == NULL) return;
	}

	if (wagon == v) return;

	DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
}

static void TrainDepotClickTrain(Window *w, int x, int y)
{
	GetDepotVehiclePtData gdvp;
	int mode;
	Vehicle *v;

	mode = GetVehicleFromTrainDepotWndPt(w, x, y, &gdvp);

	// share / copy orders
	if (_thd.place_mode && mode <= 0) {
		_place_clicked_vehicle = gdvp.head;
		return;
	}

	v = gdvp.wagon;

	switch (mode) {
	case 0: { // start dragging of vehicle
		VehicleID sel = WP(w, traindepot_d).sel;

		if (sel != INVALID_VEHICLE) {
			WP(w,traindepot_d).sel = INVALID_VEHICLE;
			TrainDepotMoveVehicle(v, sel, gdvp.head);
		} else if (v != NULL) {
			WP(w,traindepot_d).sel = v->index;
			SetObjectToPlaceWnd(GetVehiclePalette(v) | GetTrainImage(v, DIR_W), 4, w);
			SetWindowDirty(w);
		}
		break;
	}

	case -1: // show info window
		ShowTrainViewWindow(v);
		break;

	case -2: // click start/stop flag
		DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
		break;
	}
}

/**
 * Clones a train
 * @param *v is the original vehicle to clone
 * @param *w is the window of the depot where the clone is build
 */
static void HandleCloneVehClick(const Vehicle *v, const Window *w)
{
	if (v == NULL || v->type != VEH_Train) return;

	// for train vehicles: subtype 0 for locs and not zero for others
	if (!IsFrontEngine(v)) {
		v = GetFirstVehicleInChain(v);
		// Do nothing when clicking on a train in depot with no loc attached
		if (!IsFrontEngine(v)) return;
	}

	DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneTrain,
		CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)
	);

	ResetObjectToPlace();
}

static void ClonePlaceObj(const Window *w)
{
	Vehicle *v = CheckMouseOverVehicle();

	if (v != NULL) HandleCloneVehClick(v, w);
}

static void TrainDepotWndProc(Window *w, WindowEvent *e)
{
	switch (e->event) {
	case WE_PAINT:
		DrawTrainDepotWindow(w);
		break;

	case WE_CLICK: {
		switch (e->click.widget) {
		case 8:
			ResetObjectToPlace();
			ShowBuildTrainWindow(w->window_number);
			break;
		case 10:
			ResetObjectToPlace();
			ScrollMainWindowToTile(w->window_number);
			break;
		case 6:
			TrainDepotClickTrain(w, e->click.pt.x, e->click.pt.y);
			break;
		case 9: /* clone button */
			InvalidateWidget(w, 9);
			TOGGLEBIT(w->click_state, 9);

			if (HASBIT(w->click_state, 9)) {
				_place_clicked_vehicle = NULL;
				SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
			} else {
				ResetObjectToPlace();
			}
			break;

		}
	} break;

	case WE_PLACE_OBJ:
		ClonePlaceObj(w);
		break;

	case WE_ABORT_PLACE_OBJ:
		CLRBIT(w->click_state, 9);
		InvalidateWidget(w, 9);
		break;

	// check if a vehicle in a depot was clicked..
	case WE_MOUSELOOP: {
		const Vehicle *v = _place_clicked_vehicle;

		// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button
		if (v != NULL && HASBIT(w->click_state, 9)) {
			_place_clicked_vehicle = NULL;
			HandleCloneVehClick(v, w);
		}
	} break;


	case WE_DESTROY:
		DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
		break;

	case WE_DRAGDROP: {
		switch (e->click.widget) {
		case 4: case 5: {
			Vehicle *v;
			int sell_cmd;

			/* sell vehicle */
			if (w->disabled_state & (1 << e->click.widget))
				return;

			if (WP(w,traindepot_d).sel == INVALID_VEHICLE)
				return;

			v = GetVehicle(WP(w,traindepot_d).sel);

			WP(w,traindepot_d).sel = INVALID_VEHICLE;
			SetWindowDirty(w);

			HandleButtonClick(w, e->click.widget);

			sell_cmd = (e->click.widget == 5 || _ctrl_pressed) ? 1 : 0;

			if (!IsFrontEngine(v)) {
				DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE));
			} else {
				_backup_orders_tile = v->tile;
				BackupVehicleOrders(v, _backup_orders_data);
				if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE)))
					_backup_orders_tile = 0;
			}
		}	break;

		case 6: {
				GetDepotVehiclePtData gdvp;
				VehicleID sel = WP(w,traindepot_d).sel;

				WP(w,traindepot_d).sel = INVALID_VEHICLE;
				SetWindowDirty(w);

				if (GetVehicleFromTrainDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &gdvp) == 0 &&
						sel != INVALID_VEHICLE) {
					if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
						DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
					} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
						TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
					} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
						ShowTrainViewWindow(gdvp.head);
					}
				}
			} break;

		default:
			WP(w,traindepot_d).sel = INVALID_VEHICLE;
			SetWindowDirty(w);
			break;
		}
		} break;
	case WE_RESIZE: {
		/* Update the scroll + matrix */
		w->vscroll.cap += e->sizing.diff.y / 14;
		w->hscroll.cap += e->sizing.diff.x;
		w->widget[6].unkA = (w->vscroll.cap << 8) + 1;
	} break;
	}
}

static const Widget _train_depot_widgets[] = {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   348,     0,    13, STR_8800_TRAIN_DEPOT,  STR_018C_WINDOW_TITLE_DRAG_THIS},
{  WWT_STICKYBOX,     RESIZE_LR,    14,   349,   360,     0,    13, 0x0,                   STR_STICKY_BUTTON},

{      WWT_PANEL,    RESIZE_LRB,    14,   326,   348,    14,    13, 0x0,                   STR_NULL},
{      WWT_PANEL,   RESIZE_LRTB,    14,   326,   348,    14,    54, 0x2A9,                 STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE},
{      WWT_PANEL,   RESIZE_LRTB,    14,   326,   348,    55,   109, 0x2BF,                 STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},

{     WWT_MATRIX,     RESIZE_RB,    14,     0,   325,    14,    97, 0x601,                 STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   349,   360,    14,   109, 0x0,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   116,   110,   121, STR_8815_NEW_VEHICLES, STR_8840_BUILD_NEW_TRAIN_VEHICLE},
{WWT_NODISTXTBTN,     RESIZE_TB,    14,   117,   232,   110,   121, STR_CLONE_TRAIN,       STR_CLONE_TRAIN_DEPOT_INFO},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   233,   348,   110,   121, STR_00E4_LOCATION,     STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},


{ WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   325,    98,   109, 0x0,                   STR_HSCROLL_BAR_SCROLLS_LIST},
{      WWT_PANEL,    RESIZE_RTB,    14,   349,   348,   110,   121, 0x0,                   STR_NULL},

{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   349,   360,   110,   121, 0x0,                   STR_RESIZE_BUTTON},
{   WIDGETS_END},
};

static const WindowDesc _train_depot_desc = {
	-1, -1, 361, 122,
	WC_VEHICLE_DEPOT,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
	_train_depot_widgets,
	TrainDepotWndProc
};


void ShowTrainDepotWindow(TileIndex tile)
{
	Window *w;

	w = AllocateWindowDescFront(&_train_depot_desc, tile);
	if (w) {
		w->caption_color = GetTileOwner(w->window_number);
		w->vscroll.cap = 6;
		w->hscroll.cap = 10 * 29;
		w->resize.step_width = 1;
		w->resize.step_height = 14;
		WP(w,traindepot_d).sel = INVALID_VEHICLE;
		_backup_orders_tile = 0;
	}
}

static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)
{
	switch (e->event) {
	case WE_PAINT: {
		const Vehicle *v = GetVehicle(w->window_number);

		SetDParam(0, v->string_id);
		SetDParam(1, v->unitnumber);
		DrawWindowWidgets(w);


		/* TODO: Support for custom GRFSpecial-specified refitting! --pasky */
		WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);

		if (WP(w,refit_d).cargo != CT_INVALID) {
			int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_RAIL_VEHICLE);
			if (!CmdFailed(cost)) {
				SetDParam(2, cost);
				SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
				SetDParam(1, _returned_refit_capacity);
				DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
			}
		}
	}	break;

	case WE_CLICK:
		switch (e->click.widget) {
		case 2: { /* listbox */
			int y = e->click.pt.y - 25;
			if (y >= 0) {
				WP(w,refit_d).sel = y / 10;
				SetWindowDirty(w);
			}
		} break;
		case 4: /* refit button */
			if (WP(w,refit_d).cargo != CT_INVALID) {
				const Vehicle *v = GetVehicle(w->window_number);
				if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE)))
					DeleteWindow(w);
			}
			break;
		}
		break;
	}
}


static const Widget _rail_vehicle_refit_widgets[] = {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                            STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   239,     0,    13, STR_983B_REFIT,                      STR_018C_WINDOW_TITLE_DRAG_THIS},
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,    14,   135, 0x0,                                 STR_RAIL_SELECT_TYPE_OF_CARGO_FOR},
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   239,   136,   157, 0x0,                                 STR_NULL},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   239,   158,   169, STR_RAIL_REFIT_VEHICLE,              STR_RAIL_REFIT_TO_CARRY_HIGHLIGHTED},
{      WWT_LABEL,   RESIZE_NONE,     0,     0,   239,    13,    26, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, STR_NULL},
{   WIDGETS_END},
};

static const WindowDesc _rail_vehicle_refit_desc = {
	-1,-1, 240, 170,
	WC_VEHICLE_REFIT,WC_VEHICLE_VIEW,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
	_rail_vehicle_refit_widgets,
	RailVehicleRefitWndProc,
};

static void ShowRailVehicleRefitWindow(Vehicle *v)
{
	Window *w;
	DeleteWindowById(WC_VEHICLE_REFIT, v->index);
	_alloc_wnd_parent_num = v->index;
	w = AllocateWindowDesc(&_rail_vehicle_refit_desc);
	w->window_number = v->index;
	w->caption_color = v->owner;
	WP(w,refit_d).sel = -1;
}

static const Widget _train_view_widgets[] = {
{   WWT_CLOSEBOX,  RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW },
{    WWT_CAPTION, RESIZE_RIGHT, 14,  11, 237,   0,  13, STR_882E,        STR_018C_WINDOW_TITLE_DRAG_THIS },
{  WWT_STICKYBOX,    RESIZE_LR, 14, 238, 249,   0,  13, 0x0,             STR_STICKY_BUTTON },
{      WWT_PANEL,    RESIZE_RB, 14,   0, 231,  14, 121, 0x0,             STR_NULL },
{          WWT_6,    RESIZE_RB, 14,   2, 229,  16, 119, 0x0,             STR_NULL },
{ WWT_PUSHIMGBTN,   RESIZE_RTB, 14,   0, 237, 122, 133, 0x0,             STR_8846_CURRENT_TRAIN_ACTION_CLICK },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  14,  31, 0x2AB,           STR_8848_CENTER_MAIN_VIEW_ON_TRAIN },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  32,  49, 0x2AD,           STR_8849_SEND_TRAIN_TO_DEPOT },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  50,  67, 0x2B1,           STR_884A_FORCE_TRAIN_TO_PROCEED },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  68,  85, 0x2CB,           STR_884B_REVERSE_DIRECTION_OF_TRAIN },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  86, 103, 0x2B2,           STR_8847_SHOW_TRAIN_S_ORDERS },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249, 104, 121, 0x2B3,           STR_884C_SHOW_TRAIN_DETAILS },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  68,  85, 0x2B4,           STR_RAIL_REFIT_VEHICLE_TO_CARRY },
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  32,  49, SPR_CLONE_TRAIN, STR_CLONE_TRAIN_INFO },
{      WWT_PANEL,   RESIZE_LRB, 14, 232, 249, 122, 121, 0x0,             STR_NULL },
{  WWT_RESIZEBOX,  RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0,             STR_NULL },
{ WIDGETS_END }
};

static void ShowTrainDetailsWindow(const Vehicle *v);

static void TrainViewWndProc(Window *w, WindowEvent *e)
{
	switch (e->event) {
	case WE_PAINT: {
		const Vehicle *v, *u;
		StringID str;

		v = GetVehicle(w->window_number);

		if (v->owner != _local_player) {
			w->disabled_state = 0x3380;
		} else {
			w->disabled_state = 0;

			SETBIT(w->disabled_state, 12);

			/* See if any vehicle can be refitted */
			for (u = v; u != NULL; u = u->next) {
				if (EngInfo(u->engine_type)->refit_mask != 0 ||
						(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) {
					CLRBIT(w->disabled_state, 12);
					/* We have a refittable carriage, bail out */
					break;
				}
			}
		}

		/* draw widgets & caption */
		SetDParam(0, v->string_id);
		SetDParam(1, v->unitnumber);
		DrawWindowWidgets(w);

		if (v->u.rail.crash_anim_pos != 0) {
			str = STR_8863_CRASHED;
		} else if (v->breakdown_ctr == 1) {
			str = STR_885C_BROKEN_DOWN;
		} else if (v->vehstatus & VS_STOPPED) {
			if (v->u.rail.last_speed == 0) {
				if (v->u.rail.cached_power == 0) {
					str = STR_TRAIN_NO_POWER;
				} else {
					str = STR_8861_STOPPED;
				}
			} else {
				SetDParam(0, v->u.rail.last_speed);
				str = STR_TRAIN_STOPPING + _patches.vehicle_speed;
			}
		} else {
			switch (v->current_order.type) {
			case OT_GOTO_STATION: {
				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
				SetDParam(0, v->current_order.station);
				SetDParam(1, v->u.rail.last_speed);
			} break;

			case OT_GOTO_DEPOT: {
				Depot *dep = GetDepot(v->current_order.station);
				SetDParam(0, dep->town_index);
				str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
				SetDParam(1, v->u.rail.last_speed);
			} break;

			case OT_LOADING:
			case OT_LEAVESTATION:
				str = STR_882F_LOADING_UNLOADING;
				break;

			case OT_GOTO_WAYPOINT: {
				SetDParam(0, v->current_order.station);
				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
				SetDParam(1, v->u.rail.last_speed);
				break;
			}

			default:
				if (v->num_orders == 0) {
					str = STR_NO_ORDERS + _patches.vehicle_speed;
					SetDParam(0, v->u.rail.last_speed);
				} else {
					str = STR_EMPTY;
				}
				break;
			}
		}

		/* draw the flag plus orders */
		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1);
		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
		DrawWindowViewport(w);
	}	break;

	case WE_CLICK: {
		int wid = e->click.widget;
		Vehicle *v = GetVehicle(w->window_number);

		switch (wid) {
		case 5: /* start/stop train */
			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
			break;
		case 6:	/* center main view */
			ScrollMainWindowTo(v->x_pos, v->y_pos);
			break;
		case 7:	/* goto depot */
			/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
			DoCommandP(v->tile, v->index, 0, NULL, CMD_TRAIN_GOTO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT));
			break;
		case 8: /* force proceed */
			DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
			break;
		case 9: /* reverse direction */
			DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));
			break;
		case 10: /* show train orders */
			ShowOrdersWindow(v);
			break;
		case 11: /* show train details */
			ShowTrainDetailsWindow(v);
			break;
		case 12:
			ShowRailVehicleRefitWindow(v);
			break;
		case 13:
			DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
			break;
		}
	} break;

	case WE_RESIZE:
		w->viewport->width  += e->sizing.diff.x;
		w->viewport->height += e->sizing.diff.y;
		w->viewport->virtual_width  += e->sizing.diff.x;
		w->viewport->virtual_height += e->sizing.diff.y;
		break;

	case WE_DESTROY:
		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
		break;

	case WE_MOUSELOOP: {
		const Vehicle *v = GetVehicle(w->window_number);
		uint32 h;

		assert(v->type == VEH_Train);
		h = CheckTrainStoppedInDepot(v) >= 0 ? (1 << 9)| (1 << 7) : (1 << 12) | (1 << 13);
		if (h != w->hidden_state) {
			w->hidden_state = h;
			SetWindowDirty(w);
		}
		break;
	}

	}
}

static const WindowDesc _train_view_desc = {
	-1,-1, 250, 134,
	WC_VEHICLE_VIEW,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
	_train_view_widgets,
	TrainViewWndProc
};

void ShowTrainViewWindow(const Vehicle *v)
{
	Window *w = AllocateWindowDescFront(&_train_view_desc,v->index);

	if (w != NULL) {
		w->caption_color = v->owner;
		AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);
	}
}

static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
{
	int num;
	StringID str;

	if (v->cargo_cap != 0) {
		num = v->cargo_count;
		str = STR_8812_EMPTY;
		if (num != 0) {
			SetDParam(0, v->cargo_type);
			SetDParam(1, num);
			SetDParam(2, v->cargo_source);
			str = STR_8813_FROM;
		}
		DrawString(x, y, str, 0);
	}
}

static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
{
	const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);

	if (!(rvi->flags & RVI_WAGON)) {
		SetDParam(0, GetCustomEngineName(v->engine_type));
		SetDParam(1, v->build_year);
		SetDParam(2, v->value);
		DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);
	} else {
		SetDParam(0, GetCustomEngineName(v->engine_type));
		SetDParam(1, v->value);
		DrawString(x, y, STR_882D_VALUE, 0x10);
	}
}

static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y)
{
	if (v->cargo_cap != 0) {
		SetDParam(0, _cargoc.names_long[v->cargo_type]);
		SetDParam(1, v->cargo_cap);
		DrawString(x, y, STR_013F_CAPACITY, 0);
	}
}

typedef void TrainDetailsDrawerProc(const Vehicle *v, int x, int y);

static TrainDetailsDrawerProc * const _train_details_drawer_proc[3] = {
	TrainDetailsCargoTab,
	TrainDetailsInfoTab,
	TrainDetailsCapacityTab,
};

static void DrawTrainDetailsWindow(Window *w)
{
	const Vehicle *v, *u;
	uint16 tot_cargo[NUM_CARGO][2];	// count total cargo ([0]-actual cargo, [1]-total cargo)
	int i,num,x,y,sel;
	byte det_tab = WP(w, traindetails_d).tab;

	/* Count number of vehicles */
	num = 0;

	// det_tab == 3 <-- Total Cargo tab
	if (det_tab == 3)	// reset tot_cargo array to 0 values
		memset(tot_cargo, 0, sizeof(tot_cargo));

	u = v = GetVehicle(w->window_number);
	do {
		if (det_tab != 3)
			num++;
		else {
			tot_cargo[u->cargo_type][0] += u->cargo_count;
			tot_cargo[u->cargo_type][1] += u->cargo_cap;
		}
	} while ((u = GetNextVehicle(u)) != NULL);

	/*	set scroll-amount seperately from counting, as to not
			compute num double for more carriages of the same type
	*/
	if (det_tab == 3) {
		for (i = 0; i != NUM_CARGO; i++) {
			if (tot_cargo[i][1] > 0)	// only count carriages that the train has
				num++;
		}
		num++;	// needs one more because first line is description string
	}

	SetVScrollCount(w, num);

	w->disabled_state = 1 << (det_tab + 9);
	if (v->owner != _local_player)
		w->disabled_state |= (1 << 2);

	if (!_patches.servint_trains) // disable service-scroller when interval is set to disabled
		w->disabled_state |= (1 << 6) | (1 << 7);

	SetDParam(0, v->string_id);
	SetDParam(1, v->unitnumber);
	DrawWindowWidgets(w);

	num = v->age / 366;
	SetDParam(1, num);

	x = 2;

	SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
	SetDParam(2, v->max_age / 366);
	SetDParam(3, GetTrainRunningCost(v) >> 8);
	DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0);

	SetDParam(2, v->u.rail.cached_max_speed);
	SetDParam(1, v->u.rail.cached_power);
	SetDParam(0, v->u.rail.cached_weight);
	DrawString(x, 25, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);

	SetDParam(0, v->profit_this_year);
	SetDParam(1, v->profit_last_year);
	DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0);

	SetDParam(0, 100 * (v->reliability>>8) >> 8);
	SetDParam(1, v->breakdowns_since_last_service);
	DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0);

	SetDParam(0, v->service_interval);
	SetDParam(1, v->date_of_last_service);
	DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);

	y = 57;
	sel = w->vscroll.pos;

	// draw the first 3 details tabs
	if (det_tab != 3) {
		x = 1;
		for (;;) {
			if (--sel < 0 && sel >= -w->vscroll.cap) {
				int dx = 0;
				u = v;
				do {
					PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
					DrawSprite(GetTrainImage(u, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
					dx += u->u.rail.cached_veh_length;
					u = u->next;
				} while (u != NULL && IsArticulatedPart(u));
				_train_details_drawer_proc[WP(w,traindetails_d).tab](v, x + WagonLengthToPixels(dx) + 2, y + 2);
				y += 14;
			}
			if ((v = GetNextVehicle(v)) == NULL)
				return;
		}
	} else {
		// draw total cargo tab
		DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
		for (i = 0; i != NUM_CARGO; i++) {
			if (tot_cargo[i][1] > 0 && --sel < 0 && sel > -w->vscroll.cap) {
				y += 14;
				// STR_013F_TOTAL_CAPACITY			:{LTBLUE}- {CARGO} ({SHORTCARGO})
				SetDParam(0, i);								// {CARGO} #1
				SetDParam(1, tot_cargo[i][0]);	// {CARGO} #2
				SetDParam(2, i);								// {SHORTCARGO} #1
				SetDParam(3, tot_cargo[i][1]);	// {SHORTCARGO} #2
				DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0);
			}
		}
	}
}

static void TrainDetailsWndProc(Window *w, WindowEvent *e)
{
	switch (e->event) {
	case WE_PAINT:
		DrawTrainDetailsWindow(w);
		break;
	case WE_CLICK: {
		int mod;
		const Vehicle *v;
		switch (e->click.widget) {
		case 2: /* name train */
			v = GetVehicle(w->window_number);
			SetDParam(0, v->unitnumber);
			ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL);
			break;
		case 6:	/* inc serv interval */
			mod = _ctrl_pressed? 5 : 10;
			goto do_change_service_int;

		case 7: /* dec serv interval */
			mod = _ctrl_pressed? -5 : -10;
do_change_service_int:
			v = GetVehicle(w->window_number);

			mod = GetServiceIntervalClamped(mod + v->service_interval);
			if (mod == v->service_interval) return;

			DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
			break;
		/* details buttons*/
		case 9:		// Cargo
		case 10:	// Information
		case 11:	// Capacities
		case 12:	// Total cargo
			CLRBIT(w->disabled_state, 9);
			CLRBIT(w->disabled_state, 10);
			CLRBIT(w->disabled_state, 11);
			CLRBIT(w->disabled_state, 12);
			SETBIT(w->disabled_state, e->click.widget);
			WP(w,traindetails_d).tab = e->click.widget - 9;
			SetWindowDirty(w);
			break;
		}
	} break;

	case WE_ON_EDIT_TEXT:
		if (e->edittext.str[0] != '\0') {
			_cmd_text = e->edittext.str;
			DoCommandP(0, w->window_number, 0, NULL,
				CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
		}
		break;

	case WE_RESIZE:
		if (e->sizing.diff.y == 0) break;

		w->vscroll.cap += e->sizing.diff.y / 14;
		w->widget[4].unkA = (w->vscroll.cap << 8) + 1;
		break;
	}
}

static const Widget _train_details_widgets[] = {
{   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION, RESIZE_NONE,   14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PUSHTXTBTN, RESIZE_NONE,   14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
{      WWT_PANEL, RESIZE_NONE,   14,   0, 369,  14,  55, 0x0,                  STR_NULL},
{     WWT_MATRIX, RESIZE_BOTTOM, 14,   0, 357,  56, 139, 0x601,                STR_NULL},
{  WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
{      WWT_PANEL, RESIZE_TB,     14,  11, 369, 140, 151, 0x0,                  STR_NULL},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
{  WWT_RESIZEBOX, RESIZE_TB,     14, 358, 369, 152, 163, 0x0,                  STR_RESIZE_BUTTON},
{   WIDGETS_END},
};


static const WindowDesc _train_details_desc = {
	-1,-1, 370, 164,
	WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
	_train_details_widgets,
	TrainDetailsWndProc
};


static void ShowTrainDetailsWindow(const Vehicle *v)
{
	Window *w;
	VehicleID veh = v->index;

	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);

	_alloc_wnd_parent_num = veh;
	w = AllocateWindowDesc(&_train_details_desc);

	w->window_number = veh;
	w->caption_color = v->owner;
	w->vscroll.cap = 6;
	w->widget[4].unkA = (w->vscroll.cap << 8) + 1;

	w->resize.step_height = 14;
	w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */

	WP(w,traindetails_d).tab = 0;
}

static const Widget _player_trains_widgets[] = {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   312,     0,    13, STR_881B_TRAINS,       STR_018C_WINDOW_TITLE_DRAG_THIS},
{  WWT_STICKYBOX,     RESIZE_LR,    14,   313,   324,     0,    13, 0x0,                   STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,           STR_SORT_ORDER_TIP},
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,                   STR_SORT_CRITERIA_TIP},
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,              STR_SORT_CRITERIA_TIP},
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   324,    14,    25, 0x0,                   STR_NULL},
{     WWT_MATRIX,     RESIZE_RB,    14,     0,   312,    26,   207, 0x701,                 STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   313,   324,    26,   207, 0x0,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   156,   208,   219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES},
{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   157,   312,   208,   219, STR_REPLACE_VEHICLES,  STR_REPLACE_HELP},
{      WWT_PANEL,    RESIZE_RTB,    14,   313,   312,   208,   219, 0x0,                   STR_NULL},
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   313,   324,   208,   219, 0x0,                   STR_RESIZE_BUTTON},
{   WIDGETS_END},
};

static const Widget _other_player_trains_widgets[] = {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   312,     0,    13, STR_881B_TRAINS,       STR_018C_WINDOW_TITLE_DRAG_THIS},
{  WWT_STICKYBOX,     RESIZE_LR,    14,   313,   324,     0,    13, 0x0,                   STR_STICKY_BUTTON},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,           STR_SORT_ORDER_TIP},
{      WWT_PANEL,   RESIZE_NONE,    14,    81,   235,    14,    25, 0x0,                   STR_SORT_CRITERIA_TIP},
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   236,   247,    14,    25, STR_0225,              STR_SORT_CRITERIA_TIP},
{      WWT_PANEL,  RESIZE_RIGHT,    14,   248,   324,    14,    25, 0x0,                   STR_NULL},
{     WWT_MATRIX,     RESIZE_RB,    14,     0,   312,    26,   207, 0x701,                 STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   313,   324,    26,   207, 0x0,                   STR_0190_SCROLL_BAR_SCROLLS_LIST},
{      WWT_PANEL,    RESIZE_RTB,    14,     0,   312,   208,   219, 0x0,                   STR_NULL},
{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   313,   324,   208,   219, 0x0,                   STR_RESIZE_BUTTON},
{   WIDGETS_END},
};

static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
{
	StationID station = GB(w->window_number, 16, 16);
	PlayerID owner = GB(w->window_number, 0, 8);
	vehiclelist_d *vl = &WP(w, vehiclelist_d);

	switch (e->event) {
	case WE_PAINT: {
		int x = 2;
		int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
		int max;
		int i;

		BuildVehicleList(vl, VEH_Train, owner, station);
		SortVehicleList(vl);

		SetVScrollCount(w, vl->list_length);

		// disable 'Sort By' tooltip on Unsorted sorting criteria
		if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);

		/* draw the widgets */
		{
			const Player *p = GetPlayer(owner);
			if (station == INVALID_STATION) {
				/* Company Name -- (###) Trains */
				SetDParam(0, p->name_1);
				SetDParam(1, p->name_2);
				SetDParam(2, w->vscroll.count);
				w->widget[1].unkA = STR_881B_TRAINS;
			} else {
				/* Station Name -- (###) Trains */
				SetDParam(0, station);
				SetDParam(1, w->vscroll.count);
				w->widget[1].unkA = STR_SCHEDULED_TRAINS;
			}
			DrawWindowWidgets(w);
		}
		/* draw sorting criteria string */
		DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
		/* draw arrow pointing up/down for ascending/descending sorting */
		DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10);

		max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
		for (i = w->vscroll.pos; i < max; ++i) {
			const Vehicle* v = vl->sort_list[i];
			StringID str;

			assert(v->type == VEH_Train && v->owner == owner);

			DrawTrainImage(v, x + 21, y + 6, w->hscroll.cap, 0, INVALID_VEHICLE);
			DrawVehicleProfitButton(v, x, y + 13);

			SetDParam(0, v->unitnumber);
			if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN)) {
				str = STR_021F;
			} else {
				str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
			}
			DrawString(x, y + 2, str, 0);

			SetDParam(0, v->profit_this_year);
			SetDParam(1, v->profit_last_year);
			DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);

			if (v->string_id != STR_SV_TRAIN_NAME) {
				SetDParam(0, v->string_id);
				DrawString(x + 21, y, STR_01AB, 0);
			}

			y += PLY_WND_PRC__SIZE_OF_ROW_SMALL;
		}
		break;
	}

	case WE_CLICK: {
		switch (e->click.widget) {
		case 3: /* Flip sorting method ascending/descending */
			vl->flags ^= VL_DESC;
			vl->flags |= VL_RESORT;
			_sorting.train.order = !!(vl->flags & VL_DESC);
			SetWindowDirty(w);
			break;

		case 4: case 5:/* Select sorting criteria dropdown menu */
			ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0);
			return;

		case 7: { /* Matrix to show vehicles */
			uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
			const Vehicle *v;

			if (id_v >= w->vscroll.cap) return; // click out of bounds

			id_v += w->vscroll.pos;

			if (id_v >= vl->list_length) return; // click out of list bound

			v = vl->sort_list[id_v];

			assert(v->type == VEH_Train && IsFrontEngine(v) && v->owner == owner);

			ShowTrainViewWindow(v);
		} break;

		case 9: /* Build new Vehicle */
			if (!IsWindowOfPrototype(w, _player_trains_widgets)) break;
			ShowBuildTrainWindow(0);
			break;

		case 10:
			if (!IsWindowOfPrototype(w, _player_trains_widgets)) break;
			ShowReplaceVehicleWindow(VEH_Train);
			break;

		}
	}	break;

	case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
		if (vl->sort_type != e->dropdown.index) {
			// value has changed -> resort
			vl->flags |= VL_RESORT;
			vl->sort_type = e->dropdown.index;
			_sorting.train.criteria = vl->sort_type;

			// enable 'Sort By' if a sorter criteria is chosen
			if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
		}
		SetWindowDirty(w);
		break;

	case WE_CREATE: /* set up resort timer */
		vl->sort_list = NULL;
		vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1));
		vl->sort_type = _sorting.train.criteria;
		vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
		break;

	case WE_DESTROY:
		free((void*)vl->sort_list);
		break;

	case WE_TICK: /* resort the list every 20 seconds orso (10 days) */
		if (--vl->resort_timer == 0) {
			DEBUG(misc, 1) ("Periodic resort trains list player %d station %d",
				owner, station);
			vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
			vl->flags |= VL_RESORT;
			SetWindowDirty(w);
		}
		break;

	case WE_RESIZE:
		/* Update the scroll + matrix */
		w->hscroll.cap += e->sizing.diff.x;
		w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
		break;
	}
}

static const WindowDesc _player_trains_desc = {
	-1, -1, 325, 220,
	WC_TRAINS_LIST,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
	_player_trains_widgets,
	PlayerTrainsWndProc
};

static const WindowDesc _other_player_trains_desc = {
	-1, -1, 325, 220,
	WC_TRAINS_LIST,0,
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
	_other_player_trains_widgets,
	PlayerTrainsWndProc
};

void ShowPlayerTrains(PlayerID player, StationID station)
{
	Window *w;

	if (player == _local_player) {
		w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player);
	} else {
		w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
	}
	if (w != NULL) {
		w->caption_color = player;
		w->hscroll.cap = 10 * 29;
		w->vscroll.cap = 7; // maximum number of vehicles shown
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL;
		w->resize.step_width = 1;
		w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
	}
}