400 } |
400 } |
401 |
401 |
402 switch (variable) { |
402 switch (variable) { |
403 /* Calculated station variables */ |
403 /* Calculated station variables */ |
404 case 0x40: |
404 case 0x40: |
405 if (!HASBIT(_svc.valid, 0)) { _svc.v40 = GetPlatformInfoHelper(tile, false, false, false); SETBIT(_svc.valid, 0); } |
405 if (!HasBit(_svc.valid, 0)) { _svc.v40 = GetPlatformInfoHelper(tile, false, false, false); SETBIT(_svc.valid, 0); } |
406 return _svc.v40; |
406 return _svc.v40; |
407 |
407 |
408 case 0x41: |
408 case 0x41: |
409 if (!HASBIT(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(tile, true, false, false); SETBIT(_svc.valid, 1); } |
409 if (!HasBit(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(tile, true, false, false); SETBIT(_svc.valid, 1); } |
410 return _svc.v41; |
410 return _svc.v41; |
411 |
411 |
412 case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8); |
412 case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8); |
413 case 0x43: return st->owner; // Station owner |
413 case 0x43: return st->owner; // Station owner |
414 case 0x44: return 2; // PBS status |
414 case 0x44: return 2; // PBS status |
415 case 0x45: |
415 case 0x45: |
416 if (!HASBIT(_svc.valid, 2)) { _svc.v45 = GetRailContinuationInfo(tile); SETBIT(_svc.valid, 2); } |
416 if (!HasBit(_svc.valid, 2)) { _svc.v45 = GetRailContinuationInfo(tile); SETBIT(_svc.valid, 2); } |
417 return _svc.v45; |
417 return _svc.v45; |
418 |
418 |
419 case 0x46: |
419 case 0x46: |
420 if (!HASBIT(_svc.valid, 3)) { _svc.v46 = GetPlatformInfoHelper(tile, false, false, true); SETBIT(_svc.valid, 3); } |
420 if (!HasBit(_svc.valid, 3)) { _svc.v46 = GetPlatformInfoHelper(tile, false, false, true); SETBIT(_svc.valid, 3); } |
421 return _svc.v46; |
421 return _svc.v46; |
422 |
422 |
423 case 0x47: |
423 case 0x47: |
424 if (!HASBIT(_svc.valid, 4)) { _svc.v47 = GetPlatformInfoHelper(tile, true, false, true); SETBIT(_svc.valid, 4); } |
424 if (!HasBit(_svc.valid, 4)) { _svc.v47 = GetPlatformInfoHelper(tile, true, false, true); SETBIT(_svc.valid, 4); } |
425 return _svc.v47; |
425 return _svc.v47; |
426 |
426 |
427 case 0x48: { // Accepted cargo types |
427 case 0x48: { // Accepted cargo types |
428 CargoID cargo_type; |
428 CargoID cargo_type; |
429 uint32 value = 0; |
429 uint32 value = 0; |
430 |
430 |
431 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
431 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
432 if (HASBIT(st->goods[cargo_type].acceptance_pickup, GoodsEntry::PICKUP)) SETBIT(value, cargo_type); |
432 if (HasBit(st->goods[cargo_type].acceptance_pickup, GoodsEntry::PICKUP)) SETBIT(value, cargo_type); |
433 } |
433 } |
434 return value; |
434 return value; |
435 } |
435 } |
436 case 0x49: |
436 case 0x49: |
437 if (!HASBIT(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SETBIT(_svc.valid, 5); } |
437 if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SETBIT(_svc.valid, 5); } |
438 return _svc.v49; |
438 return _svc.v49; |
439 |
439 |
440 /* Variables which use the parameter */ |
440 /* Variables which use the parameter */ |
441 /* Variables 0x60 to 0x65 are handled separately below */ |
441 /* Variables 0x60 to 0x65 are handled separately below */ |
442 |
442 |
522 default: |
522 default: |
523 cargo = st->goods[cargo_type].cargo.Count(); |
523 cargo = st->goods[cargo_type].cargo.Count(); |
524 break; |
524 break; |
525 } |
525 } |
526 |
526 |
527 if (HASBIT(statspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h); |
527 if (HasBit(statspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h); |
528 cargo = min(0xfff, cargo); |
528 cargo = min(0xfff, cargo); |
529 |
529 |
530 if (cargo > statspec->cargo_threshold) { |
530 if (cargo > statspec->cargo_threshold) { |
531 if (group->g.real.num_loading > 0) { |
531 if (group->g.real.num_loading > 0) { |
532 set = ((cargo - statspec->cargo_threshold) * group->g.real.num_loading) / (4096 - statspec->cargo_threshold); |
532 set = ((cargo - statspec->cargo_threshold) * group->g.real.num_loading) / (4096 - statspec->cargo_threshold); |
749 statspec = GetCustomStationSpec(sclass, station); |
749 statspec = GetCustomStationSpec(sclass, station); |
750 if (statspec == NULL) return false; |
750 if (statspec == NULL) return false; |
751 |
751 |
752 relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE); |
752 relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE); |
753 |
753 |
754 if (HASBIT(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) { |
754 if (HasBit(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) { |
755 uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE); |
755 uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE); |
756 if (callback != CALLBACK_FAILED) tile = callback; |
756 if (callback != CALLBACK_FAILED) tile = callback; |
757 } |
757 } |
758 |
758 |
759 if (statspec->renderdata == NULL) { |
759 if (statspec->renderdata == NULL) { |
761 } else { |
761 } else { |
762 sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis]; |
762 sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis]; |
763 } |
763 } |
764 |
764 |
765 image = sprites->ground_sprite; |
765 image = sprites->ground_sprite; |
766 if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { |
766 if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { |
767 image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); |
767 image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); |
768 image += rti->custom_ground_offset; |
768 image += rti->custom_ground_offset; |
769 } else { |
769 } else { |
770 image += rti->total_offset; |
770 image += rti->total_offset; |
771 } |
771 } |
808 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
808 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
809 bool IsStationTileBlocked(TileIndex tile) |
809 bool IsStationTileBlocked(TileIndex tile) |
810 { |
810 { |
811 const StationSpec* statspec = GetStationSpec(tile); |
811 const StationSpec* statspec = GetStationSpec(tile); |
812 |
812 |
813 return statspec != NULL && HASBIT(statspec->blocked, GetStationGfx(tile)); |
813 return statspec != NULL && HasBit(statspec->blocked, GetStationGfx(tile)); |
814 } |
814 } |
815 |
815 |
816 /* Check if a rail station tile is electrifiable. |
816 /* Check if a rail station tile is electrifiable. |
817 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
817 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
818 bool IsStationTileElectrifiable(TileIndex tile) |
818 bool IsStationTileElectrifiable(TileIndex tile) |
819 { |
819 { |
820 const StationSpec* statspec = GetStationSpec(tile); |
820 const StationSpec* statspec = GetStationSpec(tile); |
821 |
821 |
822 return |
822 return |
823 statspec == NULL || |
823 statspec == NULL || |
824 HASBIT(statspec->pylons, GetStationGfx(tile)) || |
824 HasBit(statspec->pylons, GetStationGfx(tile)) || |
825 !HASBIT(statspec->wires, GetStationGfx(tile)); |
825 !HasBit(statspec->wires, GetStationGfx(tile)); |
826 } |
826 } |