|
@@ -403,25 +403,25 @@ uint32 Station::GetNewGRFVariable(const
|
|
|
case 0x8A: return this->had_vehicle_of_type;
|
|
|
case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
|
|
|
case 0xF2: return (this->truck_stops != nullptr) ? this->truck_stops->status : 0;
|
|
|
case 0xF3: return (this->bus_stops != nullptr) ? this->bus_stops->status : 0;
|
|
|
case 0xF6: return this->airport.flags;
|
|
|
case 0xF7: return GB(this->airport.flags, 8, 8);
|
|
|
}
|
|
|
|
|
|
/* Handle cargo variables with parameter, 0x60 to 0x65 and 0x69 */
|
|
|
if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
|
|
|
CargoID c = GetCargoTranslation(parameter, object.grffile);
|
|
|
|
|
|
if (c == CT_INVALID) {
|
|
|
if (!IsValidCargoID(c)) {
|
|
|
switch (variable) {
|
|
|
case 0x62: return 0xFFFFFFFF;
|
|
|
case 0x64: return 0xFF00;
|
|
|
default: return 0;
|
|
|
}
|
|
|
}
|
|
|
const GoodsEntry *ge = &this->goods[c];
|
|
|
|
|
|
switch (variable) {
|
|
|
case 0x60: return std::min(ge->cargo.TotalCount(), 4095u);
|
|
|
case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0;
|
|
|
case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
|
|
@@ -922,25 +922,25 @@ void TriggerStationAnimation(BaseStation
|
|
|
* to bother with any further processing. */
|
|
|
if (!HasBit(st->cached_anim_triggers, trigger)) return;
|
|
|
|
|
|
uint16 random_bits = Random();
|
|
|
ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
|
|
|
|
|
|
/* Check all tiles over the station to check if the specindex is still in use */
|
|
|
for (TileIndex tile : area) {
|
|
|
if (st->TileBelongsToRailStation(tile)) {
|
|
|
const StationSpec *ss = GetStationSpec(tile);
|
|
|
if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
|
|
|
CargoID cargo;
|
|
|
if (cargo_type == CT_INVALID) {
|
|
|
if (!IsValidCargoID(cargo_type)) {
|
|
|
cargo = CT_INVALID;
|
|
|
} else {
|
|
|
cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
|
|
|
}
|
|
|
StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), (uint8)trigger | (cargo << 8));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Trigger station randomisation
|
|
@@ -953,25 +953,25 @@ void TriggerStationRandomisation(Station
|
|
|
{
|
|
|
/* List of coverage areas for each animation trigger */
|
|
|
static const TriggerArea tas[] = {
|
|
|
TA_WHOLE, TA_WHOLE, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM
|
|
|
};
|
|
|
|
|
|
/* Get Station if it wasn't supplied */
|
|
|
if (st == nullptr) st = Station::GetByTile(trigger_tile);
|
|
|
|
|
|
/* Check the cached cargo trigger bitmask to see if we need
|
|
|
* to bother with any further processing. */
|
|
|
if (st->cached_cargo_triggers == 0) return;
|
|
|
if (cargo_type != CT_INVALID && !HasBit(st->cached_cargo_triggers, cargo_type)) return;
|
|
|
if (IsValidCargoID(cargo_type) && !HasBit(st->cached_cargo_triggers, cargo_type)) return;
|
|
|
|
|
|
uint32 whole_reseed = 0;
|
|
|
ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
|
|
|
|
|
|
CargoTypes empty_mask = 0;
|
|
|
if (trigger == SRT_CARGO_TAKEN) {
|
|
|
/* Create a bitmask of completely empty cargo types to be matched */
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
|
|
if (st->goods[i].cargo.TotalCount() == 0) {
|
|
|
SetBit(empty_mask, i);
|
|
|
}
|
|
|
}
|
|
@@ -984,25 +984,25 @@ void TriggerStationRandomisation(Station
|
|
|
/* Check all tiles over the station to check if the specindex is still in use */
|
|
|
for (TileIndex tile : area) {
|
|
|
if (st->TileBelongsToRailStation(tile)) {
|
|
|
const StationSpec *ss = GetStationSpec(tile);
|
|
|
if (ss == nullptr) continue;
|
|
|
|
|
|
/* Cargo taken "will only be triggered if all of those
|
|
|
* cargo types have no more cargo waiting." */
|
|
|
if (trigger == SRT_CARGO_TAKEN) {
|
|
|
if ((ss->cargo_triggers & ~empty_mask) != 0) continue;
|
|
|
}
|
|
|
|
|
|
if (cargo_type == CT_INVALID || HasBit(ss->cargo_triggers, cargo_type)) {
|
|
|
if (!IsValidCargoID(cargo_type) || HasBit(ss->cargo_triggers, cargo_type)) {
|
|
|
StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
|
|
|
object.waiting_triggers = st->waiting_triggers;
|
|
|
|
|
|
const SpriteGroup *group = object.Resolve();
|
|
|
if (group == nullptr) continue;
|
|
|
|
|
|
used_triggers |= object.used_triggers;
|
|
|
|
|
|
uint32 reseed = object.GetReseedSum();
|
|
|
if (reseed != 0) {
|
|
|
whole_reseed |= reseed;
|
|
|
reseed >>= 16;
|