309 |
309 |
310 for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) { |
310 for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) { |
311 uint32 ts = GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0); |
311 uint32 ts = GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0); |
312 if (ts != 0) { |
312 if (ts != 0) { |
313 /* If there is any track on the tile, set the bit in the second byte */ |
313 /* If there is any track on the tile, set the bit in the second byte */ |
314 SETBIT(res, i + 8); |
314 SetBit(res, i + 8); |
315 |
315 |
316 /* If any track reaches our exit direction, set the bit in the lower byte */ |
316 /* If any track reaches our exit direction, set the bit in the lower byte */ |
317 if (ts & DiagdirReachesTracks(*diagdir)) SETBIT(res, i); |
317 if (ts & DiagdirReachesTracks(*diagdir)) SetBit(res, i); |
318 } |
318 } |
319 } |
319 } |
320 |
320 |
321 return res; |
321 return res; |
322 } |
322 } |
390 case 0x47: |
390 case 0x47: |
391 case 0x49: return 0x2110000; // Platforms, tracks & position |
391 case 0x49: return 0x2110000; // Platforms, tracks & position |
392 case 0x42: return 0; // Rail type (XXX Get current type from GUI?) |
392 case 0x42: return 0; // Rail type (XXX Get current type from GUI?) |
393 case 0x43: return _current_player; // Station owner |
393 case 0x43: return _current_player; // Station owner |
394 case 0x44: return 2; // PBS status |
394 case 0x44: return 2; // PBS status |
395 case 0xFA: return clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value |
395 case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value |
396 } |
396 } |
397 |
397 |
398 *available = false; |
398 *available = false; |
399 return UINT_MAX; |
399 return UINT_MAX; |
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 |
449 case 0xF1: return st->airport_type; |
449 case 0xF1: return st->airport_type; |
450 case 0xF2: return st->truck_stops->status; |
450 case 0xF2: return st->truck_stops->status; |
451 case 0xF3: return st->bus_stops->status; |
451 case 0xF3: return st->bus_stops->status; |
452 case 0xF6: return st->airport_flags; |
452 case 0xF6: return st->airport_flags; |
453 case 0xF7: return GB(st->airport_flags, 8, 8); |
453 case 0xF7: return GB(st->airport_flags, 8, 8); |
454 case 0xFA: return clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); |
454 case 0xFA: return Clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); |
455 } |
455 } |
456 |
456 |
457 /* Handle cargo variables with parameter, 0x60 to 0x65 */ |
457 /* Handle cargo variables with parameter, 0x60 to 0x65 */ |
458 if (variable >= 0x60 && variable <= 0x65) { |
458 if (variable >= 0x60 && variable <= 0x65) { |
459 CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile); |
459 CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile); |
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 } |