mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use SQInteger for generic numbers in script_station
parent
446ebaa6b9
commit
a9a55f2153
|
@ -50,7 +50,7 @@ template<bool Tfrom, bool Tvia>
|
|||
}
|
||||
|
||||
template<bool Tfrom, bool Tvia>
|
||||
/* static */ int32 ScriptStation::CountCargoWaiting(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::CountCargoWaiting(StationID station_id,
|
||||
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id,
|
||||
|
@ -74,31 +74,31 @@ template<bool Tfrom, bool Tvia>
|
|||
return cargo_count;
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
|
||||
/* static */ SQInteger ScriptStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoWaiting<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoWaitingFrom(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoWaitingFrom(StationID station_id,
|
||||
StationID from_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoWaiting<true, false>(station_id, from_station_id, STATION_INVALID, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoWaitingVia(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoWaitingVia(StationID station_id,
|
||||
StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoWaiting<false, true>(station_id, STATION_INVALID, via_station_id, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoWaitingFromVia(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoWaitingFromVia(StationID station_id,
|
||||
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoWaiting<true, true>(station_id, from_station_id, via_station_id, cargo_id);
|
||||
}
|
||||
|
||||
template<bool Tfrom, bool Tvia>
|
||||
/* static */ int32 ScriptStation::CountCargoPlanned(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::CountCargoPlanned(StationID station_id,
|
||||
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
if (!ScriptStation::IsCargoRequestValid<Tfrom, Tvia>(station_id, from_station_id,
|
||||
|
@ -115,24 +115,24 @@ template<bool Tfrom, bool Tvia>
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoPlanned(StationID station_id, CargoID cargo_id)
|
||||
/* static */ SQInteger ScriptStation::GetCargoPlanned(StationID station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoPlanned<false, false>(station_id, STATION_INVALID, STATION_INVALID, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoPlannedFrom(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoPlannedFrom(StationID station_id,
|
||||
StationID from_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoPlanned<true, false>(station_id, from_station_id, STATION_INVALID, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoPlannedVia(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoPlannedVia(StationID station_id,
|
||||
StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoPlanned<false, true>(station_id, STATION_INVALID, via_station_id, cargo_id);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoPlannedFromVia(StationID station_id,
|
||||
/* static */ SQInteger ScriptStation::GetCargoPlannedFromVia(StationID station_id,
|
||||
StationID from_station_id, StationID via_station_id, CargoID cargo_id)
|
||||
{
|
||||
return CountCargoPlanned<true, true>(station_id, from_station_id, via_station_id, cargo_id);
|
||||
|
@ -146,14 +146,14 @@ template<bool Tfrom, bool Tvia>
|
|||
return ::Station::Get(station_id)->goods[cargo_id].HasRating();
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCargoRating(StationID station_id, CargoID cargo_id)
|
||||
/* static */ SQInteger ScriptStation::GetCargoRating(StationID station_id, CargoID cargo_id)
|
||||
{
|
||||
if (!ScriptStation::HasCargoRating(station_id, cargo_id)) return -1;
|
||||
|
||||
return ::ToPercent8(::Station::Get(station_id)->goods[cargo_id].rating);
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetCoverageRadius(ScriptStation::StationType station_type)
|
||||
/* static */ SQInteger ScriptStation::GetCoverageRadius(ScriptStation::StationType station_type)
|
||||
{
|
||||
if (station_type == STATION_AIRPORT) return -1;
|
||||
if (!HasExactlyOneBit(station_type)) return -1;
|
||||
|
@ -169,21 +169,21 @@ template<bool Tfrom, bool Tvia>
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetStationCoverageRadius(StationID station_id)
|
||||
/* static */ SQInteger ScriptStation::GetStationCoverageRadius(StationID station_id)
|
||||
{
|
||||
if (!IsValidStation(station_id)) return -1;
|
||||
|
||||
return Station::Get(station_id)->GetCatchmentRadius();
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetDistanceManhattanToTile(StationID station_id, TileIndex tile)
|
||||
/* static */ SQInteger ScriptStation::GetDistanceManhattanToTile(StationID station_id, TileIndex tile)
|
||||
{
|
||||
if (!IsValidStation(station_id)) return -1;
|
||||
|
||||
return ScriptMap::DistanceManhattan(tile, GetLocation(station_id));
|
||||
}
|
||||
|
||||
/* static */ int32 ScriptStation::GetDistanceSquareToTile(StationID station_id, TileIndex tile)
|
||||
/* static */ SQInteger ScriptStation::GetDistanceSquareToTile(StationID station_id, TileIndex tile)
|
||||
{
|
||||
if (!IsValidStation(station_id)) return -1;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ public:
|
|||
* @pre IsValidCargo(cargo_id).
|
||||
* @return The amount of units waiting at the station.
|
||||
*/
|
||||
static int32 GetCargoWaiting(StationID station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoWaiting(StationID station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo with a specific source station there is waiting on a station.
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
* @return The amount of units waiting at the station originating from from_station_id.
|
||||
* @note source station means, the station where cargo was first loaded.
|
||||
*/
|
||||
static int32 GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoWaitingFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo with a specific via-station there is waiting on a station.
|
||||
|
@ -108,7 +108,7 @@ public:
|
|||
* @return The amount of units waiting at the station with via_station_id as next hop.
|
||||
* @note if ScriptCargo.GetCargoDistributionType(cargo_id) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
|
||||
*/
|
||||
static int32 GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoWaitingVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo with a specific via-station and source station there is waiting on a station.
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
* @return The amount of units waiting at the station with from_station_id as source and via_station_id as next hop.
|
||||
* @note if ScriptCargo.GetCargoDistributionType(cargo_id) == ScriptCargo.DT_MANUAL, then all waiting cargo will have STATION_INVALID as next hop.
|
||||
*/
|
||||
static int32 GetCargoWaitingFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoWaitingFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo was planned to pass (including production and consumption) this station per month.
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
* @pre IsValidCargo(cargo_id).
|
||||
* @return The amount of cargo units planned to pass the station per month.
|
||||
*/
|
||||
static int32 GetCargoPlanned(StationID station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoPlanned(StationID station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo from the specified origin was planned to pass (including production and consumption) this station per month.
|
||||
|
@ -145,7 +145,7 @@ public:
|
|||
* @pre IsValidCargo(cargo_id).
|
||||
* @return The amount of cargo units from the specified origin planned to pass the station per month.
|
||||
*/
|
||||
static int32 GetCargoPlannedFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoPlannedFrom(StationID station_id, StationID from_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo was planned to pass (including production and consumption) this station per month, heading for the specified next hop.
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
* @return The amount of cargo units planned to pass the station per month, going via the specified next hop.
|
||||
* @note Cargo planned to go "via" the same station that's being queried is actually planned to be consumed there.
|
||||
*/
|
||||
static int32 GetCargoPlannedVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoPlannedVia(StationID station_id, StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* See how much cargo from the specified origin was planned to pass this station per month,
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
* @note Cargo planned to go "via" the same station that's being queried is actually planned to be consumed there.
|
||||
* @note Cargo planned to pass "from" the same station that's being queried is actually produced there.
|
||||
*/
|
||||
static int32 GetCargoPlannedFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoPlannedFromVia(StationID station_id, StationID from_station_id, StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* Check whether the given cargo at the given station a rating.
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
* @pre HasCargoRating(station_id, cargo_id).
|
||||
* @return The rating in percent of the cargo on the station.
|
||||
*/
|
||||
static int32 GetCargoRating(StationID station_id, CargoID cargo_id);
|
||||
static SQInteger GetCargoRating(StationID station_id, CargoID cargo_id);
|
||||
|
||||
/**
|
||||
* Get the coverage radius of this type of station.
|
||||
|
@ -205,7 +205,7 @@ public:
|
|||
* @return The radius in tiles.
|
||||
* @note Coverage radius of airports needs to be requested via ScriptAirport::GetAirportCoverageRadius(), as it requires AirportType.
|
||||
*/
|
||||
static int32 GetCoverageRadius(ScriptStation::StationType station_type);
|
||||
static SQInteger GetCoverageRadius(ScriptStation::StationType station_type);
|
||||
|
||||
/**
|
||||
* Get the coverage radius of this station.
|
||||
|
@ -213,7 +213,7 @@ public:
|
|||
* @pre IsValidStation(station_id).
|
||||
* @return The radius in tiles.
|
||||
*/
|
||||
static int32 GetStationCoverageRadius(StationID station_id);
|
||||
static SQInteger GetStationCoverageRadius(StationID station_id);
|
||||
|
||||
/**
|
||||
* Get the manhattan distance from the tile to the ScriptStation::GetLocation()
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
* @pre IsValidStation(station_id).
|
||||
* @return The distance between station and tile.
|
||||
*/
|
||||
static int32 GetDistanceManhattanToTile(StationID station_id, TileIndex tile);
|
||||
static SQInteger GetDistanceManhattanToTile(StationID station_id, TileIndex tile);
|
||||
|
||||
/**
|
||||
* Get the square distance from the tile to the ScriptStation::GetLocation()
|
||||
|
@ -233,7 +233,7 @@ public:
|
|||
* @pre IsValidStation(station_id).
|
||||
* @return The distance between station and tile.
|
||||
*/
|
||||
static int32 GetDistanceSquareToTile(StationID station_id, TileIndex tile);
|
||||
static SQInteger GetDistanceSquareToTile(StationID station_id, TileIndex tile);
|
||||
|
||||
/**
|
||||
* Find out if this station is within the rating influence of a town.
|
||||
|
@ -299,11 +299,11 @@ private:
|
|||
StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
template<bool Tfrom, bool Tvia>
|
||||
static int32 CountCargoWaiting(StationID station_id, StationID from_station_id,
|
||||
static SQInteger CountCargoWaiting(StationID station_id, StationID from_station_id,
|
||||
StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
template<bool Tfrom, bool Tvia>
|
||||
static int32 CountCargoPlanned(StationID station_id, StationID from_station_id,
|
||||
static SQInteger CountCargoPlanned(StationID station_id, StationID from_station_id,
|
||||
StationID via_station_id, CargoID cargo_id);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue