16 #include "newgrf_callbacks.h" |
16 #include "newgrf_callbacks.h" |
17 #include "newgrf_station.h" |
17 #include "newgrf_station.h" |
18 #include "newgrf_spritegroup.h" |
18 #include "newgrf_spritegroup.h" |
19 #include "date.h" |
19 #include "date.h" |
20 #include "helpers.hpp" |
20 #include "helpers.hpp" |
|
21 #include "cargotype.h" |
21 |
22 |
22 static StationClass station_classes[STAT_CLASS_MAX]; |
23 static StationClass station_classes[STAT_CLASS_MAX]; |
23 |
24 |
24 enum { |
25 enum { |
25 MAX_SPECLIST = 255, |
26 MAX_SPECLIST = 255, |
198 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred) |
199 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred) |
199 { |
200 { |
200 uint32 retval = 0; |
201 uint32 retval = 0; |
201 |
202 |
202 if (axis == AXIS_X) { |
203 if (axis == AXIS_X) { |
203 intswap(platforms, length); |
204 Swap(platforms, length); |
204 intswap(x, y); |
205 Swap(x, y); |
205 } |
206 } |
206 |
207 |
207 /* Limit our sizes to 4 bits */ |
208 /* Limit our sizes to 4 bits */ |
208 platforms = min(15, platforms); |
209 platforms = min(15, platforms); |
209 length = min(15, length); |
210 length = min(15, length); |
444 if (st == NULL || statspec->sclass == STAT_CLASS_WAYP) { |
445 if (st == NULL || statspec->sclass == STAT_CLASS_WAYP) { |
445 return group->g.real.loading[0]; |
446 return group->g.real.loading[0]; |
446 } |
447 } |
447 |
448 |
448 switch (cargo_type) { |
449 switch (cargo_type) { |
449 case GC_INVALID: |
450 case CT_INVALID: |
450 case GC_DEFAULT_NA: |
451 case CT_DEFAULT_NA: |
451 case GC_PURCHASE: |
452 case CT_PURCHASE: |
452 cargo = 0; |
453 cargo = 0; |
453 break; |
454 break; |
454 |
455 |
455 case GC_DEFAULT: |
456 case CT_DEFAULT: |
456 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
457 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
457 cargo += GB(st->goods[cargo_type].waiting_acceptance, 0, 12); |
458 cargo += GB(st->goods[cargo_type].waiting_acceptance, 0, 12); |
458 } |
459 } |
459 break; |
460 break; |
460 |
461 |
461 default: |
462 default: |
462 cargo = GB(st->goods[_local_cargo_id_ctype[cargo_type]].waiting_acceptance, 0, 12); |
463 cargo = GB(st->goods[cargo_type].waiting_acceptance, 0, 12); |
463 break; |
464 break; |
464 } |
465 } |
465 |
466 |
466 if (HASBIT(statspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h); |
467 if (HASBIT(statspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h); |
467 cargo = min(0xfff, cargo); |
468 cargo = min(0xfff, cargo); |
503 } |
504 } |
504 |
505 |
505 static const SpriteGroup *ResolveStation(ResolverObject *object) |
506 static const SpriteGroup *ResolveStation(ResolverObject *object) |
506 { |
507 { |
507 const SpriteGroup *group; |
508 const SpriteGroup *group; |
508 CargoID ctype = GC_DEFAULT_NA; |
509 CargoID ctype = CT_DEFAULT_NA; |
509 |
510 |
510 if (object->u.station.st == NULL) { |
511 if (object->u.station.st == NULL) { |
511 /* No station, so we are in a purchase list */ |
512 /* No station, so we are in a purchase list */ |
512 ctype = GC_PURCHASE; |
513 ctype = CT_PURCHASE; |
513 } else { |
514 } else { |
514 CargoID cargo; |
|
515 |
|
516 /* Pick the first cargo that we have waiting */ |
515 /* Pick the first cargo that we have waiting */ |
517 for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) { |
516 for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) { |
518 CargoID lcid = _local_cargo_id_ctype[cargo]; |
517 const CargoSpec *cs = GetCargo(cargo); |
519 if (lcid != CT_INVALID && |
518 if (cs->IsValid() && object->u.station.statspec->spritegroup[cargo] != NULL && |
520 object->u.station.statspec->spritegroup[cargo] != NULL && |
519 GB(object->u.station.st->goods[cargo].waiting_acceptance, 0, 12) != 0) { |
521 GB(object->u.station.st->goods[lcid].waiting_acceptance, 0, 12) != 0) { |
|
522 ctype = cargo; |
520 ctype = cargo; |
523 break; |
521 break; |
524 } |
522 } |
525 } |
523 } |
526 } |
524 } |
527 |
525 |
528 group = object->u.station.statspec->spritegroup[ctype]; |
526 group = object->u.station.statspec->spritegroup[ctype]; |
529 if (group == NULL) { |
527 if (group == NULL) { |
530 ctype = GC_DEFAULT; |
528 ctype = CT_DEFAULT; |
531 group = object->u.station.statspec->spritegroup[ctype]; |
529 group = object->u.station.statspec->spritegroup[ctype]; |
532 } |
530 } |
533 |
531 |
534 if (group == NULL) return NULL; |
532 if (group == NULL) return NULL; |
535 |
533 |