Codechange: Use SQInteger for generic numbers in script_road

This commit is contained in:
glx22 2023-03-04 18:28:36 +01:00 committed by Loïc Guilloux
parent 4f6a2f31b5
commit 446ebaa6b9
2 changed files with 10 additions and 10 deletions

View File

@ -378,7 +378,7 @@ static bool NormaliseTileOffset(int32 *tile)
return false; return false;
} }
/* static */ int32 ScriptRoad::CanBuildConnectedRoadParts(ScriptTile::Slope slope_, Array<> existing, TileIndex start_, TileIndex end_) /* static */ SQInteger ScriptRoad::CanBuildConnectedRoadParts(ScriptTile::Slope slope_, Array<> existing, TileIndex start_, TileIndex end_)
{ {
::Slope slope = (::Slope)slope_; ::Slope slope = (::Slope)slope_;
int32 start = start_; int32 start = start_;
@ -399,7 +399,7 @@ static bool NormaliseTileOffset(int32 *tile)
return _settings_game.construction.build_on_slopes ? LookupWithBuildOnSlopes(slope, existing, start, end) : LookupWithoutBuildOnSlopes(slope, existing, start, end); return _settings_game.construction.build_on_slopes ? LookupWithBuildOnSlopes(slope, existing, start, end) : LookupWithoutBuildOnSlopes(slope, existing, start, end);
} }
/* static */ int32 ScriptRoad::CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end) /* static */ SQInteger ScriptRoad::CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end)
{ {
if (!::IsValidTile(tile) || !::IsValidTile(start) || !::IsValidTile(end)) return -1; if (!::IsValidTile(tile) || !::IsValidTile(start) || !::IsValidTile(end)) return -1;
if (::DistanceManhattan(tile, start) != 1 || ::DistanceManhattan(tile, end) != 1) return -1; if (::DistanceManhattan(tile, start) != 1 || ::DistanceManhattan(tile, end) != 1) return -1;
@ -450,7 +450,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD
} }
} }
/* static */ int32 ScriptRoad::GetNeighbourRoadCount(TileIndex tile) /* static */ SQInteger ScriptRoad::GetNeighbourRoadCount(TileIndex tile)
{ {
if (!::IsValidTile(tile)) return -1; if (!::IsValidTile(tile)) return -1;
if (!IsRoadTypeAvailable(GetCurrentRoadType())) return -1; if (!IsRoadTypeAvailable(GetCurrentRoadType())) return -1;
@ -625,14 +625,14 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD
return (RoadTramTypes)(1 << ::GetRoadTramType((::RoadType)roadtype)); return (RoadTramTypes)(1 << ::GetRoadTramType((::RoadType)roadtype));
} }
/* static */ int32 ScriptRoad::GetMaxSpeed(RoadType road_type) /* static */ SQInteger ScriptRoad::GetMaxSpeed(RoadType road_type)
{ {
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return -1; if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return -1;
return GetRoadTypeInfo((::RoadType)road_type)->max_speed; return GetRoadTypeInfo((::RoadType)road_type)->max_speed;
} }
/* static */ uint16 ScriptRoad::GetMaintenanceCostFactor(RoadType roadtype) /* static */ SQInteger ScriptRoad::GetMaintenanceCostFactor(RoadType roadtype)
{ {
if (!ScriptRoad::IsRoadTypeAvailable(roadtype)) return 0; if (!ScriptRoad::IsRoadTypeAvailable(roadtype)) return 0;

View File

@ -246,7 +246,7 @@ public:
* they are build or 2 when building the first part automatically * they are build or 2 when building the first part automatically
* builds the second part. -1 means the preconditions are not met. * builds the second part. -1 means the preconditions are not met.
*/ */
static int32 CanBuildConnectedRoadParts(ScriptTile::Slope slope, Array<> existing, TileIndex start, TileIndex end); static SQInteger CanBuildConnectedRoadParts(ScriptTile::Slope slope, Array<> existing, TileIndex start, TileIndex end);
/** /**
* Lookup function for building road parts independent of whether the * Lookup function for building road parts independent of whether the
@ -267,7 +267,7 @@ public:
* they are build or 2 when building the first part automatically * they are build or 2 when building the first part automatically
* builds the second part. -1 means the preconditions are not met. * builds the second part. -1 means the preconditions are not met.
*/ */
static int32 CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end); static SQInteger CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end);
/** /**
* Count how many neighbours are road. * Count how many neighbours are road.
@ -276,7 +276,7 @@ public:
* @pre IsRoadTypeAvailable(GetCurrentRoadType()). * @pre IsRoadTypeAvailable(GetCurrentRoadType()).
* @return 0 means no neighbour road; max value is 4. * @return 0 means no neighbour road; max value is 4.
*/ */
static int32 GetNeighbourRoadCount(TileIndex tile); static SQInteger GetNeighbourRoadCount(TileIndex tile);
/** /**
* Gets the tile in front of a road depot. * Gets the tile in front of a road depot.
@ -561,7 +561,7 @@ public:
* This is mph / 0.8, which is roughly 0.5 km/h. * This is mph / 0.8, which is roughly 0.5 km/h.
* To get km/h multiply this number by 2.01168. * To get km/h multiply this number by 2.01168.
*/ */
static int32 GetMaxSpeed(RoadType road_type); static SQInteger GetMaxSpeed(RoadType road_type);
/** /**
* Get the maintenance cost factor of a road type. * Get the maintenance cost factor of a road type.
@ -569,7 +569,7 @@ public:
* @pre IsRoadTypeAvailable(roadtype) * @pre IsRoadTypeAvailable(roadtype)
* @return Maintenance cost factor of the roadtype. * @return Maintenance cost factor of the roadtype.
*/ */
static uint16 GetMaintenanceCostFactor(RoadType roadtype); static SQInteger GetMaintenanceCostFactor(RoadType roadtype);
private: private: