@@ -28,7 +28,7 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
uint64 _station_tile_cache_hash = 0;
|
||||
uint64_t _station_tile_cache_hash = 0;
|
||||
|
||||
template <typename Tspec, typename Tid, Tid Tmax>
|
||||
/* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults()
|
||||
@@ -102,9 +102,9 @@ struct ETileArea : TileArea {
|
||||
* if centered, C/P start from the centre and c/p are not available.
|
||||
* @return Platform information in bit-stuffed format.
|
||||
*/
|
||||
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
|
||||
uint32_t GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
|
||||
{
|
||||
uint32 retval = 0;
|
||||
uint32_t retval = 0;
|
||||
|
||||
if (axis == AXIS_X) {
|
||||
Swap(platforms, length);
|
||||
@@ -163,7 +163,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch
|
||||
}
|
||||
|
||||
|
||||
static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred)
|
||||
static uint32_t GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred)
|
||||
{
|
||||
int tx = TileX(tile);
|
||||
int ty = TileY(tile);
|
||||
@@ -179,7 +179,7 @@ static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_
|
||||
}
|
||||
|
||||
|
||||
static uint32 GetRailContinuationInfo(TileIndex tile)
|
||||
static uint32_t GetRailContinuationInfo(TileIndex tile)
|
||||
{
|
||||
/* Tile offsets and exit dirs for X axis */
|
||||
static const Direction x_dir[8] = { DIR_SW, DIR_NE, DIR_SE, DIR_NW, DIR_S, DIR_E, DIR_W, DIR_N };
|
||||
@@ -195,7 +195,7 @@ static uint32 GetRailContinuationInfo(TileIndex tile)
|
||||
const Direction *dir = axis == AXIS_X ? x_dir : y_dir;
|
||||
const DiagDirection *diagdir = axis == AXIS_X ? x_exits : y_exits;
|
||||
|
||||
uint32 res = 0;
|
||||
uint32_t res = 0;
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
|
||||
@@ -221,13 +221,13 @@ static uint32 GetRailContinuationInfo(TileIndex tile)
|
||||
|
||||
|
||||
/* Station Resolver Functions */
|
||||
/* virtual */ uint32 StationScopeResolver::GetRandomBits() const
|
||||
/* virtual */ uint32_t StationScopeResolver::GetRandomBits() const
|
||||
{
|
||||
return (this->st == nullptr ? 0 : this->st->random_bits) | (this->tile == INVALID_TILE ? 0 : GetStationTileRandomBits(this->tile) << 16);
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ uint32 StationScopeResolver::GetTriggers() const
|
||||
/* virtual */ uint32_t StationScopeResolver::GetTriggers() const
|
||||
{
|
||||
return this->st == nullptr ? 0 : this->st->waiting_triggers;
|
||||
}
|
||||
@@ -239,13 +239,13 @@ static uint32 GetRailContinuationInfo(TileIndex tile)
|
||||
* several tiles that may be called multiple times per Resolve().
|
||||
*/
|
||||
static struct {
|
||||
uint32 v40;
|
||||
uint32 v41;
|
||||
uint32 v45;
|
||||
uint32 v46;
|
||||
uint32 v47;
|
||||
uint32 v49;
|
||||
uint8 valid; ///< Bits indicating what variable is valid (for each bit, \c 0 is invalid, \c 1 is valid).
|
||||
uint32_t v40;
|
||||
uint32_t v41;
|
||||
uint32_t v45;
|
||||
uint32_t v46;
|
||||
uint32_t v47;
|
||||
uint32_t v49;
|
||||
uint8_t valid; ///< Bits indicating what variable is valid (for each bit, \c 0 is invalid, \c 1 is valid).
|
||||
} _svc;
|
||||
|
||||
/**
|
||||
@@ -268,18 +268,18 @@ TownScopeResolver *StationResolverObject::GetTown()
|
||||
return this->town_scope;
|
||||
}
|
||||
|
||||
uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScopeResolver::NearbyStationInfoMode mode) const
|
||||
uint32_t StationScopeResolver::GetNearbyStationInfo(uint32_t parameter, StationScopeResolver::NearbyStationInfoMode mode) const
|
||||
{
|
||||
TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
|
||||
|
||||
if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF;
|
||||
|
||||
uint32 grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid;
|
||||
uint32_t grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid;
|
||||
bool perpendicular = GetRailStationAxis(this->tile) != GetRailStationAxis(nearby_tile);
|
||||
bool same_station = this->st->TileBelongsToRailStation(nearby_tile);
|
||||
uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
|
||||
uint32_t res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
|
||||
|
||||
uint16 localidx = 0;
|
||||
uint16_t localidx = 0;
|
||||
if (IsCustomStationSpecIndex(nearby_tile)) {
|
||||
const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
|
||||
localidx = ssl.localidx;
|
||||
@@ -289,14 +289,14 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope
|
||||
switch (mode) {
|
||||
case NearbyStationInfoMode::Standard:
|
||||
default:
|
||||
return res | ClampTo<uint8>(localidx);
|
||||
return res | ClampTo<uint8_t>(localidx);
|
||||
|
||||
case NearbyStationInfoMode::V2:
|
||||
return (res << 8) | localidx;
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ uint32 StationScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const
|
||||
/* virtual */ uint32_t StationScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const
|
||||
{
|
||||
if (this->st == nullptr) {
|
||||
/* Station does not exist, so we're in a purchase list or the land slope check callback. */
|
||||
@@ -314,7 +314,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope
|
||||
TileIndex tile = this->tile;
|
||||
if (parameter != 0) tile = GetNearbyTile(parameter, tile, true, this->axis); // only perform if it is required
|
||||
|
||||
uint32 result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask);
|
||||
uint32_t result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask);
|
||||
if (extra->mask & SLOPE_EW) {
|
||||
Slope tileh = GetTileSlope(tile);
|
||||
if (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E)) result ^= SLOPE_EW;
|
||||
@@ -323,7 +323,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xFA: return ClampTo<uint16>(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
|
||||
case 0xFA: return ClampTo<uint16_t>(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value
|
||||
}
|
||||
|
||||
extra->available = false;
|
||||
@@ -375,7 +375,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope
|
||||
TileIndex tile = this->tile;
|
||||
if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
|
||||
|
||||
uint32 result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask);
|
||||
uint32_t result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask);
|
||||
if (extra->mask & SLOPE_EW) {
|
||||
Slope tileh = GetTileSlope(tile);
|
||||
if (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E)) result ^= SLOPE_EW;
|
||||
@@ -414,7 +414,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope
|
||||
return this->st->GetNewGRFVariable(this->ro, variable, parameter, &(extra->available));
|
||||
}
|
||||
|
||||
uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const
|
||||
uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint16_t variable, byte parameter, bool *available) const
|
||||
{
|
||||
switch (variable) {
|
||||
case 0x48: { // Accepted cargo types
|
||||
@@ -444,7 +444,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable,
|
||||
const GoodsEntry *ge = &this->goods[c];
|
||||
|
||||
switch (variable) {
|
||||
case 0x60: return std::min<uint32>(ge->CargoTotalCount(), 4095);
|
||||
case 0x60: return std::min<uint32_t>(ge->CargoTotalCount(), 4095);
|
||||
case 0x61: return ge->HasVehicleEverTriedLoading() && ge->IsSupplyAllowed() ? ge->time_since_pickup : 0;
|
||||
case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
|
||||
case 0x63: return ge->data != nullptr ? ge->data->cargo.PeriodsInTransit() : 0;
|
||||
@@ -480,7 +480,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable,
|
||||
return UINT_MAX;
|
||||
}
|
||||
|
||||
uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const
|
||||
uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &object, uint16_t variable, byte parameter, bool *available) const
|
||||
{
|
||||
switch (variable) {
|
||||
case 0x48: return 0; // Accepted cargo types
|
||||
@@ -562,7 +562,7 @@ GrfSpecFeature StationResolverObject::GetFeature() const
|
||||
return GSF_STATIONS;
|
||||
}
|
||||
|
||||
uint32 StationResolverObject::GetDebugID() const
|
||||
uint32_t StationResolverObject::GetDebugID() const
|
||||
{
|
||||
return this->station_scope.statspec->grf_prop.local_id;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ uint32 StationResolverObject::GetDebugID() const
|
||||
* @param callback_param2 Second parameter (var 18) of the callback.
|
||||
*/
|
||||
StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *base_station, TileIndex tile, RailType rt,
|
||||
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
|
||||
CallbackID callback, uint32_t callback_param1, uint32_t callback_param2)
|
||||
: ResolverObject(statspec->grf_prop.grffile, callback, callback_param1, callback_param2),
|
||||
station_scope(*this, statspec, base_station, tile, rt), town_scope(nullptr)
|
||||
{
|
||||
@@ -625,7 +625,7 @@ StationResolverObject::~StationResolverObject()
|
||||
* @param var10 Value to put in variable 10; normally 0; 1 when resolving the groundsprite and SSF_SEPARATE_GROUND is set.
|
||||
* @return First sprite of the Action 1 spriteset to use, minus an offset of 0x42D to accommodate for weird NewGRF specs.
|
||||
*/
|
||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt, uint32 var10)
|
||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt, uint32_t var10)
|
||||
{
|
||||
StationResolverObject object(statspec, st, tile, rt, CBID_NO_CALLBACK, var10);
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
@@ -655,7 +655,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS
|
||||
}
|
||||
|
||||
|
||||
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt)
|
||||
uint16_t GetStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt)
|
||||
{
|
||||
StationResolverObject object(statspec, st, tile, rt, callback, param1, param2);
|
||||
return object.ResolveCallback();
|
||||
@@ -681,7 +681,7 @@ CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_til
|
||||
(numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff)));
|
||||
object.station_scope.axis = axis;
|
||||
|
||||
uint16 cb_res = object.ResolveCallback();
|
||||
uint16_t cb_res = object.ResolveCallback();
|
||||
|
||||
/* Failed callback means success. */
|
||||
if (cb_res == CALLBACK_FAILED) return CommandCost();
|
||||
@@ -800,13 +800,13 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
||||
if (statspec == nullptr) return false;
|
||||
|
||||
if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
|
||||
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE, railtype);
|
||||
uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE, railtype);
|
||||
if (callback != CALLBACK_FAILED) tile = callback & ~1;
|
||||
}
|
||||
|
||||
uint32 total_offset = rti->GetRailtypeSpriteOffset();
|
||||
uint32 relocation = 0;
|
||||
uint32 ground_relocation = 0;
|
||||
uint32_t total_offset = rti->GetRailtypeSpriteOffset();
|
||||
uint32_t relocation = 0;
|
||||
uint32_t ground_relocation = 0;
|
||||
const NewGRFSpriteLayout *layout = nullptr;
|
||||
DrawTileSprites tmp_rail_layout;
|
||||
|
||||
@@ -823,9 +823,9 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
||||
if (layout != nullptr) {
|
||||
/* Sprite layout which needs preprocessing */
|
||||
bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND);
|
||||
uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
|
||||
for (uint8 var10 : SetBitIterator(var10_values)) {
|
||||
uint32 var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, railtype, var10);
|
||||
uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
|
||||
for (uint8_t var10 : SetBitIterator(var10_values)) {
|
||||
uint32_t var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, railtype, var10);
|
||||
layout->ProcessRegisters(var10, var10_relocation, separate_ground);
|
||||
}
|
||||
|
||||
@@ -870,7 +870,7 @@ const StationSpec *GetStationSpec(TileIndex t)
|
||||
}
|
||||
|
||||
/** Wrapper for animation control, see GetStationCallback. */
|
||||
uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
|
||||
uint16_t GetAnimStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
|
||||
{
|
||||
return GetStationCallback(callback, param1, param2, statspec, st, tile, INVALID_RAILTYPE);
|
||||
}
|
||||
@@ -892,7 +892,7 @@ void AnimateStationTile(TileIndex tile)
|
||||
StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, SSF_CB141_RANDOM_BITS));
|
||||
}
|
||||
|
||||
uint8 GetStationTileAnimationSpeed(TileIndex tile)
|
||||
uint8_t GetStationTileAnimationSpeed(TileIndex tile)
|
||||
{
|
||||
const StationSpec *ss = GetStationSpec(tile);
|
||||
if (ss == nullptr) return 0;
|
||||
@@ -914,7 +914,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
|
||||
* to bother with any further processing. */
|
||||
if (!HasBit(st->cached_anim_triggers, trigger)) return;
|
||||
|
||||
uint16 random_bits = Random();
|
||||
uint16_t 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 */
|
||||
@@ -928,7 +928,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
|
||||
} 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));
|
||||
StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), (uint8_t)trigger | (cargo << 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,7 +956,7 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan
|
||||
if (st->cached_cargo_triggers == 0) return;
|
||||
if (cargo_type != CT_INVALID && !HasBit(st->cached_cargo_triggers, cargo_type)) return;
|
||||
|
||||
uint32 whole_reseed = 0;
|
||||
uint32_t whole_reseed = 0;
|
||||
ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
|
||||
|
||||
/* Bitmask of completely empty cargo types to be matched. */
|
||||
@@ -964,7 +964,7 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan
|
||||
|
||||
/* Store triggers now for var 5F */
|
||||
SetBit(st->waiting_triggers, trigger);
|
||||
uint32 used_triggers = 0;
|
||||
uint32_t used_triggers = 0;
|
||||
|
||||
/* Check all tiles over the station to check if the specindex is still in use */
|
||||
for (TileIndex tile : area) {
|
||||
@@ -987,13 +987,13 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan
|
||||
|
||||
used_triggers |= object.used_triggers;
|
||||
|
||||
uint32 reseed = object.GetReseedSum();
|
||||
uint32_t reseed = object.GetReseedSum();
|
||||
if (reseed != 0) {
|
||||
whole_reseed |= reseed;
|
||||
reseed >>= 16;
|
||||
|
||||
/* Set individual tile random bits */
|
||||
uint8 random_bits = GetStationTileRandomBits(tile);
|
||||
uint8_t random_bits = GetStationTileRandomBits(tile);
|
||||
random_bits &= ~reseed;
|
||||
random_bits |= Random() & reseed;
|
||||
SetStationTileRandomBits(tile, random_bits);
|
||||
|
Reference in New Issue
Block a user