mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-19 03:29:26 +01:00
Codechange: Allow passing waypoints to Trigger(Station|RoadStop)Randomisation.
This commit is contained in:
parent
c0cd7cafe4
commit
bc0eaf9ac4
@ -379,8 +379,7 @@ void AnimateRoadStopTile(TileIndex tile)
|
||||
|
||||
void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type)
|
||||
{
|
||||
/* Get Station if it wasn't supplied */
|
||||
if (st == nullptr) st = BaseStation::GetByTile(trigger_tile);
|
||||
assert(st != nullptr);
|
||||
|
||||
/* Check the cached animation trigger bitmask to see if we need
|
||||
* to bother with any further processing. */
|
||||
@ -417,12 +416,13 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn
|
||||
* @param trigger trigger type
|
||||
* @param cargo_type cargo type causing the trigger
|
||||
*/
|
||||
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type)
|
||||
void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type)
|
||||
{
|
||||
if (st == nullptr) st = Station::GetByTile(tile);
|
||||
assert(st != nullptr);
|
||||
|
||||
/* Check the cached cargo trigger bitmask to see if we need
|
||||
* to bother with any further processing. */
|
||||
* to bother with any further processing.
|
||||
* Note: cached_roadstop_cargo_triggers must be non-zero even for cargo-independent triggers. */
|
||||
if (st->cached_roadstop_cargo_triggers == 0) return;
|
||||
if (IsValidCargoType(cargo_type) && !HasBit(st->cached_roadstop_cargo_triggers, cargo_type)) return;
|
||||
|
||||
@ -431,7 +431,10 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, StationRandomTrig
|
||||
uint32_t whole_reseed = 0;
|
||||
|
||||
/* Bitmask of completely empty cargo types to be matched. */
|
||||
CargoTypes empty_mask = (trigger == StationRandomTrigger::CargoTaken) ? GetEmptyMask(st) : 0;
|
||||
CargoTypes empty_mask{};
|
||||
if (trigger == StationRandomTrigger::CargoTaken) {
|
||||
empty_mask = GetEmptyMask(Station::From(st));
|
||||
}
|
||||
|
||||
StationRandomTriggers used_random_triggers;
|
||||
auto process_tile = [&](TileIndex cur_tile) {
|
||||
|
@ -176,7 +176,7 @@ uint16_t GetRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t para
|
||||
void AnimateRoadStopTile(TileIndex tile);
|
||||
uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile);
|
||||
void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void TriggerRoadStopRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
|
||||
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype);
|
||||
bool GetIfClassHasNewStopsByType(const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype);
|
||||
|
@ -909,8 +909,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
|
||||
TA_TILE, TA_WHOLE, TA_WHOLE, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM, TA_WHOLE
|
||||
};
|
||||
|
||||
/* Get Station if it wasn't supplied */
|
||||
if (st == nullptr) st = BaseStation::GetByTile(trigger_tile);
|
||||
assert(st != nullptr);
|
||||
|
||||
/* Check the cached animation trigger bitmask to see if we need
|
||||
* to bother with any further processing. */
|
||||
@ -943,18 +942,18 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
|
||||
* @param trigger trigger type
|
||||
* @param cargo_type cargo type causing trigger
|
||||
*/
|
||||
void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
|
||||
void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
|
||||
{
|
||||
/* 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);
|
||||
assert(st != nullptr);
|
||||
|
||||
/* Check the cached cargo trigger bitmask to see if we need
|
||||
* to bother with any further processing. */
|
||||
* to bother with any further processing.
|
||||
* Note: cached_cargo_triggers must be non-zero even for cargo-independent triggers. */
|
||||
if (st->cached_cargo_triggers == 0) return;
|
||||
if (IsValidCargoType(cargo_type) && !HasBit(st->cached_cargo_triggers, cargo_type)) return;
|
||||
|
||||
@ -962,7 +961,10 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan
|
||||
ETileArea area = ETileArea(st, trigger_tile, tas[static_cast<size_t>(trigger)]);
|
||||
|
||||
/* Bitmask of completely empty cargo types to be matched. */
|
||||
CargoTypes empty_mask = (trigger == StationRandomTrigger::CargoTaken) ? GetEmptyMask(st) : 0;
|
||||
CargoTypes empty_mask{};
|
||||
if (trigger == StationRandomTrigger::CargoTaken) {
|
||||
empty_mask = GetEmptyMask(Station::From(st));
|
||||
}
|
||||
|
||||
/* Store triggers now for var 5F */
|
||||
st->waiting_random_triggers.Set(trigger);
|
||||
|
@ -213,7 +213,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
||||
|
||||
void AnimateStationTile(TileIndex tile);
|
||||
void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void TriggerStationRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void StationUpdateCachedTriggers(BaseStation *st);
|
||||
|
||||
#endif /* NEWGRF_STATION_H */
|
||||
|
@ -80,7 +80,8 @@ private:
|
||||
tile = TileAdd(tile, diff);
|
||||
} while (IsCompatibleTrainStationTile(tile, start) && tile != this->origin_tile);
|
||||
|
||||
TriggerStationRandomisation(nullptr, start, StationRandomTrigger::PathReservation);
|
||||
auto *st = Station::GetByTile(start);
|
||||
TriggerStationRandomisation(st, start, StationRandomTrigger::PathReservation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -113,7 +113,10 @@ bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
|
||||
case MP_STATION:
|
||||
if (HasStationRail(tile) && !HasStationReservation(tile)) {
|
||||
SetRailStationReservation(tile, true);
|
||||
if (trigger_stations && IsRailStation(tile)) TriggerStationRandomisation(nullptr, tile, StationRandomTrigger::PathReservation);
|
||||
if (trigger_stations && IsRailStation(tile)) {
|
||||
auto *st = Station::GetByTile(tile);
|
||||
TriggerStationRandomisation(st, tile, StationRandomTrigger::PathReservation);
|
||||
}
|
||||
MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user