Integer math functions. More...
Go to the source code of this file.
Functions | |
template<typename T > | |
static FORCEINLINE T | max (const T a, const T b) |
Returns the maximum of two values. | |
template<typename T > | |
static FORCEINLINE T | min (const T a, const T b) |
Returns the minimum of two values. | |
static FORCEINLINE int | min (const int a, const int b) |
Returns the minimum of two integer. | |
static FORCEINLINE uint | minu (const uint a, const uint b) |
Returns the minimum of two unsigned integers. | |
template<typename T > | |
static FORCEINLINE T | abs (const T a) |
Returns the absolute value of (scalar) variable. | |
template<typename T > | |
static FORCEINLINE T | Align (const T x, uint n) |
Return the smallest multiple of n equal or greater than x. | |
template<typename T > | |
static FORCEINLINE T * | AlignPtr (T *x, uint n) |
Return the smallest multiple of n equal or greater than x Applies to pointers only. | |
template<typename T > | |
static FORCEINLINE T | Clamp (const T a, const T min, const T max) |
Clamp a value between an interval. | |
static FORCEINLINE int | Clamp (const int a, const int min, const int max) |
Clamp an integer between an interval. | |
static FORCEINLINE uint | ClampU (const uint a, const uint min, const uint max) |
Clamp an unsigned integer between an interval. | |
static FORCEINLINE int32 | ClampToI32 (const int64 a) |
Reduce a signed 64-bit int to a signed 32-bit one. | |
static FORCEINLINE uint16 | ClampToU16 (const uint64 a) |
Reduce an unsigned 64-bit int to an unsigned 16-bit one. | |
template<typename T > | |
static FORCEINLINE T | Delta (const T a, const T b) |
Returns the (absolute) difference between two (scalar) variables. | |
template<typename T > | |
static FORCEINLINE bool | IsInsideBS (const T x, const uint base, const uint size) |
Checks if a value is between a window started at some base point. | |
template<typename T > | |
static FORCEINLINE bool | IsInsideMM (const T x, const uint min, const uint max) |
Checks if a value is in an interval. | |
template<typename T > | |
static FORCEINLINE void | Swap (T &a, T &b) |
Type safe swap operation. | |
static FORCEINLINE uint | ToPercent8 (uint i) |
Converts a "fract" value 0..255 to "percent" value 0..100. | |
static FORCEINLINE uint | ToPercent16 (uint i) |
Converts a "fract" value 0..65535 to "percent" value 0..100. | |
int | LeastCommonMultiple (int a, int b) |
Compute least common multiple (lcm) of arguments a and b, the smallest integer value that is a multiple of both a and b. | |
int | GreatestCommonDivisor (int a, int b) |
Compute greatest common divisor (gcd) of a and b. | |
static FORCEINLINE uint | CeilDiv (uint a, uint b) |
Computes ceil(a / b) for non-negative a and b. | |
static FORCEINLINE int | RoundDivSU (int a, uint b) |
Computes round(a / b) for signed a and unsigned b. |
Integer math functions.
Definition in file math_func.hpp.
static FORCEINLINE T abs | ( | const T | a | ) | [inline, static] |
Returns the absolute value of (scalar) variable.
a | The value we want to unsign |
Definition at line 95 of file math_func.hpp.
Referenced by AircraftController(), AircraftGetEntryPoint(), AIRoad::AreRoadTilesConnected(), AIRail::BuildRail(), CalcRaildirsDrawstyle(), ChangeIndustryProduction(), RoadStop::Entry::CheckIntegrity(), CheckTrainsLengths(), RoadStop::ClearDriveThrough(), DeterminePluralForm(), BaseGraphWindow::DrawGraph(), TimetableWindow::DrawWidget(), GamelogPrint(), GetTunnelBridgeLength(), BaseGraphWindow::GetValuesInterval(), HandleMouseEvents(), HandleWindowDragging(), HeightMapCoastLines(), RoadStop::MakeDriveThrough(), OverflowSafeInt< int64, INT64_MAX, INT64_MIN >::operator*=(), DiagonalTileIterator::operator++(), OverflowSafeInt< int64, INT64_MAX, INT64_MIN >::operator+=(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileT< Types >::PfCalcEstimate(), PlaceTreeAtSameHeight(), PlaceTreeGroups(), RoadStop::Entry::Rebuild(), AIRail::RemoveRail(), ReportNewsProductionChangeIndustry(), AICompany::SetLoanAmount(), SimulateDrag(), TerraformTileHeight(), TownHouseChangeInfo(), and VpSelectTilesWithMethod().
static FORCEINLINE T Align | ( | const T | x, | |
uint | n | |||
) | [inline, static] |
Return the smallest multiple of n equal or greater than x.
x | The min value | |
n | The base of the number we are searching |
Definition at line 109 of file math_func.hpp.
Referenced by TarScanner::AddFile(), AlignPtr(), SmallVector< RefitOption, 32 >::Append(), SmallVector< RefitOption, 32 >::Compact(), DrawDirtyBlocks(), MakeBMPImage(), and ViewportSign::UpdatePosition().
static FORCEINLINE T* AlignPtr | ( | T * | x, | |
uint | n | |||
) | [inline, static] |
Return the smallest multiple of n equal or greater than x Applies to pointers only.
x | The min value | |
n | The base of the number we are searching |
Definition at line 127 of file math_func.hpp.
References Align().
Referenced by Blitter_32bppOptimized::Encode().
static FORCEINLINE uint CeilDiv | ( | uint | a, | |
uint | b | |||
) | [static] |
Computes ceil(a / b) for non-negative a and b.
a | Numerator | |
b | Denominator |
Definition at line 327 of file math_func.hpp.
Referenced by AircraftController(), NWidgetMatrix::AssignSizePosition(), CalcRaildirsDrawstyle(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), StationViewWindow::DrawAcceptedCargo(), StationViewWindow::DrawCargoRatings(), DepotWindow::DrawVehicleInDepot(), SmallMapWindow::DrawWidget(), NWidgetMainToolbarContainer::GetButtonArrangement(), SmallMapWindow::GetLegendHeight(), LoadUnloadVehicle(), SmallMapWindow::OnClick(), DepotWindow::OnPaint(), Industry::RecomputeProductionMultipliers(), ReplaceChain(), ScaleByMapSize(), ScaleByMapSize1D(), and NWidgetMatrix::SetCount().
static FORCEINLINE int Clamp | ( | const int | a, | |
const int | min, | |||
const int | max | |||
) | [static] |
Clamp an integer between an interval.
This function returns a value which is between the given interval of min and max. If the given value is in this interval the value itself is returned otherwise the border of the interval is returned, according which side of the interval was 'left'.
a | The value to clamp/truncate. | |
min | The minimum of the interval. | |
max | the maximum of the interval. |
Definition at line 175 of file math_func.hpp.
static FORCEINLINE T Clamp | ( | const T | a, | |
const T | min, | |||
const T | max | |||
) | [inline, static] |
Clamp a value between an interval.
This function returns a value which is between the given interval of min and max. If the given value is in this interval the value itself is returned otherwise the border of the interval is returned, according which side of the interval was 'left'.
a | The value to clamp/truncate. | |
min | The minimum of the interval. | |
max | the maximum of the interval. |
Definition at line 151 of file math_func.hpp.
Referenced by AnimationBase< HouseAnimationBase, HouseSpec, Town, GetSimpleHouseCallback >::AnimateTile(), ChangeIndustryProduction(), ClickChangeDateCheat(), Train::ConsistChanged(), DrawRoadVehEngine(), RefitWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), EnsureVisibleCaption(), AICargo::GetCargoIncome(), Train::GetCurveSpeedLimit(), GetGlobalVariable(), AIVehicle::GetLocation(), GetSavegameFormat(), GetServiceIntervalClamped(), IndustryGetVariable(), IndustryProductionCallback(), MakeBMPImage(), CustomCurrencyWindow::OnClick(), NetworkStartServerWindow::OnClick(), CreateScenarioWindow::OnClick(), GenerateLandscapeWindow::OnClick(), TooltipsWindow::OnInitialPosition(), ErrmsgWindow::OnInitialPosition(), BuildBridgeWindow::OnInitialPosition(), ScenarioEditorToolbarWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), OrdersWindow::OnQueryTextFinished(), NetworkStartServerWindow::OnQueryTextFinished(), CreateScenarioWindow::OnQueryTextFinished(), GenerateLandscapeWindow::OnQueryTextFinished(), NetworkUDPSocketHandler::ReceiveNetworkGameInfo(), RecomputePrices(), RelocateAllWindows(), RoadVehAccelerate(), ScrollWindowTo(), SetAircraftPosition(), SetDateWindow::SetDateWindow(), SetPriceBaseMultiplier(), SetSelectionTilesDirty(), AIConfig::SetSetting(), SmallMapWindow::SetZoomLevel(), SimulateDrag(), TownHouseChangeInfo(), TranslateXYToTileCoord(), UpdateCompanyRatingAndValue(), Scrollbar::UpdatePosition(), Train::UpdateSpeed(), UpdateTownGrowRate(), UpdateViewportPosition(), VpSelectTilesWithMethod(), and Write_ValidateSetting().
static FORCEINLINE int32 ClampToI32 | ( | const int64 | a | ) | [static] |
Reduce a signed 64-bit int to a signed 32-bit one.
This function clamps a 64-bit integer to a 32-bit integer. If the 64-bit value is smaller than the smallest 32-bit integer value 0x80000000 this value is returned (the left one bit is the sign bit). If the 64-bit value is greater than the greatest 32-bit integer value 0x7FFFFFFF this value is returned. In all other cases the 64-bit value 'fits' in a 32-bits integer field and so the value is casted to int32 and returned.
a | The 64-bit value to clamps |
Definition at line 215 of file math_func.hpp.
Referenced by EngineCostSorter(), EnginePowerVsRunningCostSorter(), EngineRunningCostSorter(), HandleBankruptcyTakeover(), ParseIntList(), CompanyStationsWindow::StationWaitingSorter(), UpdateCompanyRatingAndValue(), VehicleProfitLastYearSorter(), VehicleProfitThisYearSorter(), VehicleTimeToLiveSorter(), and VehicleValueSorter().
static FORCEINLINE uint16 ClampToU16 | ( | const uint64 | a | ) | [static] |
Reduce an unsigned 64-bit int to an unsigned 16-bit one.
a | The 64-bit value to clamp |
Definition at line 227 of file math_func.hpp.
Referenced by CmdExpandTown(), and TownGetVariable().
static FORCEINLINE uint ClampU | ( | const uint | a, | |
const uint | min, | |||
const uint | max | |||
) | [static] |
Clamp an unsigned integer between an interval.
This function returns a value which is between the given interval of min and max. If the given value is in this interval the value itself is returned otherwise the border of the interval is returned, according which side of the interval was 'left'.
a | The value to clamp/truncate. | |
min | The minimum of the interval. | |
max | the maximum of the interval. |
Definition at line 196 of file math_func.hpp.
Referenced by CalcClosestStationTile(), ChangeIndustryProduction(), ConvertFromOldCompanyManagerFace(), IndustryViewWindow::OnQueryTextFinished(), and Write_ValidateSetting().
static FORCEINLINE T Delta | ( | const T | a, | |
const T | b | |||
) | [inline, static] |
Returns the (absolute) difference between two (scalar) variables.
a | The first scalar | |
b | The second scalar |
Definition at line 244 of file math_func.hpp.
Referenced by DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Ufo(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DrawTileSelection(), NPFDistanceTrack(), PlaceTreeAtSameHeight(), TerraformTileHeight(), and VpSelectTilesWithMethod().
int GreatestCommonDivisor | ( | int | a, | |
int | b | |||
) |
Compute greatest common divisor (gcd) of a and b.
a | First number. | |
b | second number. |
Definition at line 39 of file math_func.cpp.
Referenced by LeastCommonMultiple().
static FORCEINLINE bool IsInsideBS | ( | const T | x, | |
const uint | base, | |||
const uint | size | |||
) | [inline, static] |
Checks if a value is between a window started at some base point.
This function checks if the value x is between the value of base and base+size. If x equals base this returns true. If x equals base+size this returns false.
x | The value to check | |
base | The base value of the interval | |
size | The size of the interval |
Definition at line 262 of file math_func.hpp.
Referenced by CmdPlantTree(), Blitter_32bppAnim::CopyFromBuffer(), DrawTileSelection(), FindStationsNearby(), FindWindowFromPt(), NWidgetBackground::GetWidgetFromPos(), NWidgetMatrix::GetWidgetFromPos(), NWidgetPIPContainer::GetWidgetFromPos(), NWidgetStacked::GetWidgetFromPos(), NWidgetCore::GetWidgetFromPos(), NWidgetToolbarContainer::GetWidgetFromPos(), NWidgetSmallmapDisplay::GetWidgetFromPos(), NWidgetNewGRFDisplay::GetWidgetFromPos(), NWidgetServerListHeader::GetWidgetFromPos(), NewGRFInspectWindow::HasVariableParameter(), Scrollbar::IsVisible(), MoveBuoysToWaypoints(), TransparenciesWindow::OnClick(), NetworkContentListWindow::OnClick(), IndustryViewWindow::OnClick(), and Blitter_32bppAnim::PaletteAnimate().
static FORCEINLINE bool IsInsideMM | ( | const T | x, | |
const uint | min, | |||
const uint | max | |||
) | [inline, static] |
Checks if a value is in an interval.
Returns true if a value is in the interval of [min, max).
x | The value to check | |
min | The minimum of the interval | |
max | The maximum of the interval |
Definition at line 278 of file math_func.hpp.
Referenced by AddChildSpriteToFoundation(), AllocateMap(), CmdPlantTree(), CmdRemoveLongRoad(), RoadVehicle::Crash(), SmallMapWindow::DrawVehicles(), SubsidyListWindow::DrawWidget(), BuildRoadStationWindow::DrawWidget(), BuildRoadDepotWindow::DrawWidget(), BuildRailDepotWindow::DrawWidget(), BuildSignalWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), GenerateCompanyName(), GetClosestWaterDistance(), GetHalftileFoundationCorner(), GetWaterTileType(), IConsoleHistoryNavigate(), IsLock(), IsNonContinuousFoundation(), IsPtInWindowViewport(), IsShipDepot(), IsSpecialRailFoundation(), IsValidCorner(), TownAuthorityWindow::OnClick(), ScenarioEditorLandscapeGenerationWindow::OnClick(), NewGRFParametersWindow::OnClick(), MusicTrackSelectionWindow::OnClick(), SelectGameWindow::OnClick(), IndustryViewWindow::OnClick(), PerformanceRatingDetailWindow::OnClick(), GraphLegendWindow::OnClick(), CheatWindow::OnClick(), AIDebugWindow::OnClick(), AISettingsWindow::OnClick(), NetworkClientListWindow::OnMouseOver(), SmallMapWindow::OnMouseWheel(), Vehicle::PreDestructor(), RemapOldStringID(), TTDPStringIDToOTTDStringIDMapping(), and Vehicle::UpdateVisualEffect().
int LeastCommonMultiple | ( | int | a, | |
int | b | |||
) |
Compute least common multiple (lcm) of arguments a and b, the smallest integer value that is a multiple of both a and b.
a | First number. | |
b | second number. |
Definition at line 24 of file math_func.cpp.
References GreatestCommonDivisor().
Referenced by NWidgetVertical::SetupSmallestSize(), NWidgetHorizontal::SetupSmallestSize(), NWidgetStacked::SetupSmallestSize(), and NWidgetNewGRFDisplay::SetupSmallestSize().
static FORCEINLINE T max | ( | const T | a, | |
const T | b | |||
) | [inline, static] |
Returns the maximum of two values.
This function returns the greater value of two given values. If they are equal the value of a is returned.
a | The first value | |
b | The second value |
Definition at line 38 of file math_func.hpp.
Referenced by TileArea::Add(), AddKey(), AddSortableSpriteToDraw(), AircraftController(), NWidgetVertical::AssignSizePosition(), NWidgetHorizontal::AssignSizePosition(), NWidgetToolbarContainer::AssignSizePosition(), NWidgetSmallmapDisplay::AssignSizePosition(), NWidgetNewGRFDisplay::AssignSizePosition(), CalcHeightdiff(), CalcPercentVehicleFilled(), CalculateCompanyValue(), CanBuildVehicleInfrastructure(), CanExpandRailStation(), ChangeIndustryProduction(), CheckBridgeAvailability(), CheckTrainsLengths(), CmdDecreaseLoan(), CmdTerraformLand(), CommonRaiseLowerBigLand(), IndustryCargoesWindow::ComputeCargoDisplay(), IndustryCargoesWindow::ComputeIndustryDisplay(), ConvertFromOldCompanyManagerFace(), DeleteOrder(), DistanceMax(), DrawBridgePillars(), BaseGraphWindow::DrawGraph(), DrawLabel(), SmallMapWindow::DrawSmallMapColumn(), DrawString(), DrawText(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), RefitWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), SmallMapWindow::DrawWidget(), OrdersWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), EnginePowerVsRunningCostSorter(), FindStationsNearby(), Window::FindWindowPlacementAndResize(), GroundVehicle< T, Type >::GetAcceleration(), GetAcceptanceAroundTiles(), AITown::GetAllowedNoise(), NWidgetMainToolbarContainer::GetButtonArrangement(), ExpensesList::GetCategoriesWidth(), Train::GetCurrentMaxSpeed(), GetDigitWidth(), GetGlobalVariable(), SmallMapWindow::GetLegendHeight(), AIBridge::GetMaxLength(), GetProductionAroundTiles(), GetStringBoundingBox(), GetStringWidth(), GetTileMaxZ(), EndGameHighScoreBaseWindow::GetTopLeft640x480(), GetTrainDetailsWndVScroll(), BaseGraphWindow::GetValuesInterval(), GetVehicleListHeight(), Vehicle::HandleLoading(), HandleScrollbarScrolling(), HeightMapCoastLines(), HighlightDragPosition(), IndustryProductionCallback(), IniFile::LoadFromDisk(), LoadUnloadVehicle(), LocalGetWindowPlacement(), MakeButtonsColumn(), MakeDescriptionColumn(), MakeNWidget(), MakeWindowNWidgetTree(), MarkViewportDirty(), maxdim(), NetworkDrawChatMessage(), NetworkUndrawChatMessage(), NewGRFDisplay(), SmallMapWindow::OnClick(), GameDifficultyWindow::OnClick(), IndustryViewWindow::OnClick(), AIConfigWindow::OnClick(), IConsoleWindow::OnHundredthTick(), CompanyFinancesWindow::OnHundredthTick(), SmallMapWindow::OnInit(), IndustryCargoesWindow::OnInit(), SelectCompanyManagerFaceWindow::OnInit(), NetworkChatWindow::OnInitialPosition(), RefitWindow::OnInvalidateData(), RefitWindow::OnPaint(), DepotWindow::OnPaint(), BuildVehicleWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), AIDebugWindow::OnPaint(), BuildBridgeWindow::OnResize(), NewsWindow::OnTick(), ParseResolution(), GroundVehicle< T, Type >::PowerChanged(), RailClearCost(), Station::RecomputeIndustriesNear(), Window::ReInit(), RemapNewGRFStringControlCode(), ResizeWindow(), SanitizeSpriteOffset(), Scrollbar::SetCapacity(), SetSnowLine(), NWidgetLeaf::SetupSmallestSize(), NWidgetBackground::SetupSmallestSize(), NWidgetVertical::SetupSmallestSize(), NWidgetHorizontal::SetupSmallestSize(), NWidgetStacked::SetupSmallestSize(), NWidgetToolbarContainer::SetupSmallestSize(), NWidgetSmallmapDisplay::SetupSmallestSize(), NWidgetNewGRFDisplay::SetupSmallestSize(), NWidgetServerListHeader::SetupSmallestSize(), NewsWindow::SetWindowTop(), SetYearEngineAgingStops(), ShowDropDownList(), CompanyStationsWindow::StationRatingMaxSorter(), TranslateXYToTileCoord(), IndustryBuildData::TryBuildNewIndustry(), UpdateAircraftSpeed(), UpdateCompanyRatingAndValue(), Scrollbar::UpdatePosition(), BaseGraphWindow::UpdateStatistics(), UpdateTownGrowRate(), VehicleDetailsWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), GameSettingsWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), BuildRailStationWindow::UpdateWidgetSize(), BuildObjectWindow::UpdateWidgetSize(), MessageOptionsWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFInspectWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), CompanyLeagueWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), CheatWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), and VehicleMove().
static FORCEINLINE int min | ( | const int | a, | |
const int | b | |||
) | [static] |
Returns the minimum of two integer.
This function returns the smaller value of two given integers.
a | The first integer | |
b | The second integer |
Definition at line 68 of file math_func.hpp.
static FORCEINLINE T min | ( | const T | a, | |
const T | b | |||
) | [inline, static] |
Returns the minimum of two values.
This function returns the smaller value of two given values. If they are equal the value of b is returned.
a | The first value | |
b | The second value |
Definition at line 54 of file math_func.hpp.
Referenced by TileArea::Add(), AddInflation(), PacketReader::AddPacket(), AddSortableSpriteToDraw(), AircraftController(), ApplyNoise(), NWidgetNewGRFDisplay::AssignSizePosition(), AIRail::BuildNewGRFRailStation(), CHashTableT< Titem_, Thash_bits_open_ >::CalcHash(), CalculateRefitMasks(), CanExpandRailStation(), ChangeGRFNumUsedParams(), ChangeGRFParamMask(), ChangeIndustryProduction(), ChopLumberMillTrees(), TileArea::ClampToMap(), CmdDecreaseLoan(), CmdGiveMoney(), CmdTerraformLand(), CommonRaiseLowerBigLand(), Train::ConsistChanged(), DEF_UDP_RECEIVE_COMMAND(), DeliverGoodsToIndustry(), DistanceFromEdge(), DoCreateNewIndustry(), DrawCargoIcons(), SmallMapWindow::DrawSmallMap(), DrawString(), BaseVehicleListWindow::DrawVehicleListItems(), CompanyStationsWindow::DrawWidget(), OrdersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), NetworkGameWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), GenerateLandscapeWindow::DrawWidget(), DepotWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), BuildVehicleWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), ExtractTar(), FindStationsNearby(), Window::FindWindowPlacementAndResize(), FixTTOEngines(), MemoryDumper::Flush(), GroundVehicle< T, Type >::GetAcceleration(), GetAcceptanceAroundTiles(), GetAircraftFlyingAltitude(), GetClosestObject(), GetCountAndDistanceOfClosestInstance(), Train::GetCurrentMaxSpeed(), GetNewEngine(), GetOtherAqueductEnd(), GetPCPElevation(), GetPlatformInfo(), GetProductionAroundTiles(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), GetTileSlope(), GetTileZ(), BaseGraphWindow::GetValuesInterval(), HandleScrollbarScrolling(), HeightMapCoastLines(), HeightMapGenerate(), HeightMapSmoothCoastInDirection(), HeightMapSmoothSlopes(), HighlightDragPosition(), IConsoleCopyInParams(), IndustryDailyLoop(), IndustryGetVariable(), LargeWorldCallback(), SpriteLoaderGrf::LoadSprite(), LoadUnloadVehicle(), CrashLogWindows::LogModules(), MakeBMPImage(), IndustryBuildData::MonthlyLoop(), NetworkDrawChatMessage(), NetworkUndrawChatMessage(), NPFDistanceTrack(), ObjectGetVariable(), GameSettingsWindow::OnClick(), GameDifficultyWindow::OnClick(), AIConfigWindow::OnClick(), TooltipsWindow::OnInitialPosition(), AIListWindow::OnInvalidateData(), NewGRFWindow::OnKeyPress(), NetworkGameWindow::OnKeyPress(), NetworkContentListWindow::OnKeyPress(), CustomCurrencyWindow::OnQueryTextFinished(), CYapfDestinationTileRoadT< Types >::PfCalcEstimate(), CYapfDestinationTileOrStationRailT< Types >::PfCalcEstimate(), CYapfDestinationTileT< Types >::PfCalcEstimate(), PlaceTree(), GroundVehicle< T, Type >::PowerChanged(), PacketReader::Read(), NetworkHTTPSocketHandler::Receive(), Industry::RecomputeProductionMultipliers(), RelocateAllWindows(), RoadVehAccelerate(), SaveToHighScore(), SetSnowLine(), NWidgetSmallmapDisplay::SetupSmallestSize(), NewsWindow::SetWindowTop(), SlCalcNetStringLen(), CompanyStationsWindow::StationRatingMinSorter(), TileLoopClearAlps(), TownHouseChangeInfo(), TransferCargo(), TriggerIndustryProduction(), IndustryBuildData::TryBuildNewIndustry(), UpdateAircraftSpeed(), UpdateCompanyRatingAndValue(), UpdateIndustryStatistics(), UpdateLandscapingLimits(), UpdateStationAcceptance(), BaseGraphWindow::UpdateStatistics(), UpdateTownGrowRate(), TooltipsWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), VehicleMove(), vseprintf(), PacketWriter::Write(), and Write_ValidateSetting().
static FORCEINLINE uint minu | ( | const uint | a, | |
const uint | b | |||
) | [static] |
Returns the minimum of two unsigned integers.
This function returns the smaller value of two given unsigned integers.
a | The first unsigned integer | |
b | The second unsigned integer |
Definition at line 82 of file math_func.hpp.
Referenced by IndustryViewWindow::OnClick(), GenerateLandscapeWindow::OnKeyPress(), TimetableWindow::OnQueryTextFinished(), and StationsWndShowStationRating().
static FORCEINLINE int RoundDivSU | ( | int | a, | |
uint | b | |||
) | [static] |
Computes round(a / b) for signed a and unsigned b.
a | Numerator | |
b | Denominator |
Definition at line 338 of file math_func.hpp.
Referenced by IndustryViewWindow::DrawInfo(), DrawString(), DrawStringMultiLine(), ScenarioEditorLandscapeGenerationWindow::DrawWidget(), IndustryViewWindow::OnClick(), and IndustryViewWindow::OnQueryTextFinished().
static FORCEINLINE void Swap | ( | T & | a, | |
T & | b | |||
) | [inline, static] |
Type safe swap operation.
a | variable to swap with b | |
b | variable to swap with a |
Definition at line 289 of file math_func.hpp.
Referenced by AIRail::AreTilesConnected(), BuildRailClick_Remove(), CalcHeightdiff(), CmdBuildAirport(), CmdBuildBridge(), GenerateCompanyColour(), IndustryDirectoryWindow::GetCargoTransportedSortValue(), GetPlatformInfo(), GSortT(), IsInRangeInclusive(), MemReverseT(), AIConfigWindow::OnClick(), BuildRailStationWindow::OnPaint(), PlaceRail_Station(), DrawStringParams::SetPreviousColour(), TileArea::TileArea(), and UpdateTileSelection().
static FORCEINLINE uint ToPercent16 | ( | uint | i | ) | [static] |
Converts a "fract" value 0..65535 to "percent" value 0..100.
i | value to convert, range 0..65535 |
Definition at line 312 of file math_func.hpp.
Referenced by DrawVehiclePurchaseInfo(), VehicleDetailsWindow::DrawWidget(), AIVehicle::GetReliability(), AIEngine::GetReliability(), and ProcessConditionalOrder().
static FORCEINLINE uint ToPercent8 | ( | uint | i | ) | [static] |
Converts a "fract" value 0..255 to "percent" value 0..100.
i | value to convert, range 0..255 |
Definition at line 301 of file math_func.hpp.
Referenced by StationViewWindow::DrawCargoRatings(), IndustryViewWindow::DrawInfo(), AIStation::GetCargoRating(), IndustryDirectoryWindow::GetCargoTransportedPercentsIfValid(), IndustryDirectoryWindow::GetIndustryString(), AITown::GetLastMonthTransportedPercentage(), and AIIndustry::GetLastMonthTransportedPercentage().