Go to the source code of this file.
Functions | |
template<typename T> | |
static T | max (const T a, const T b) |
Returns the maximum of two values. | |
template<typename T> | |
static T | min (const T a, const T b) |
Returns the minimum of two values. | |
static int | min (const int a, const int b) |
Returns the minimum of two integer. | |
static uint | minu (const uint a, const uint b) |
Returns the minimum of two unsigned integers. | |
template<typename T> | |
static T | abs (const T a) |
Returns the absolute value of (scalar) variable. | |
template<typename T> | |
static T | Align (const T x, uint n) |
Return the smallest multiple of n equal or greater than x. | |
static int | Clamp (const int a, const int min, const int max) |
Clamp an integer between an interval. | |
static uint | ClampU (const uint a, const uint min, const uint max) |
Clamp an unsigned integer between an interval. | |
static int32 | ClampToI32 (const int64 a) |
Reduce a signed 64-bit int to a signed 32-bit one. | |
static uint16 | ClampToU16 (const uint64 a) |
Reduce an usigned 64-bit int to an unsigned 16-bit one. | |
template<typename T> | |
static T | Delta (const T a, const T b) |
Returns the (absolute) difference between two (scalar) variables. | |
template<typename T> | |
static 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 bool | IsInsideMM (const T x, const uint min, const uint max) |
Checks if a value is in an interval. | |
template<typename T> | |
void | Swap (T &a, T &b) |
Type safe swap operation. |
Definition in file math_func.hpp.
static T abs | ( | const T | a | ) | [inline, static] |
Returns the absolute value of (scalar) variable.
a | The value we want to unsign |
Definition at line 85 of file math_func.hpp.
Referenced by AircraftController(), AircraftGetEntryPoint(), CalcRaildirsDrawstyle(), ChangeIndustryProduction(), CheckTrainsLengths(), DoPlaceMoreTrees(), DrawGraph(), GetTunnelBridgeLength(), HeightMapCoastLines(), OverflowSafeInt< signed __int64, INT64_MAX, INT64_MIN >::operator*=(), OverflowSafeInt< signed __int64, INT64_MAX, INT64_MIN >::operator+=(), CYapfDestinationTileT< Types >::PfCalcEstimate(), PlaceTreeAtSameHeight(), ReportNewsProductionChangeIndustry(), TerraformTileHeight(), TownHouseChangeInfo(), and VpSelectTilesWithMethod().
static 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 98 of file math_func.hpp.
Referenced by DrawDirtyBlocks(), and TarListAddFile().
static int Clamp | ( | const int | a, | |
const int | min, | |||
const int | max | |||
) | [inline, 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 120 of file math_func.hpp.
Referenced by ChangeIndustryProduction(), CheckDifficultyLevels(), CmdBuildIndustry(), CmdSetAutoReplace(), DispatchMouseWheelEvent(), GetGlobalVariable(), GetServiceIntervalClamped(), GetTrainAcceleration(), GuiShowTooltipsWithArgs(), HouseGetVariable(), IncHouseConstructionTick(), IndustryGetVariable(), IndustryProductionCallback(), PopupMainToolbMenu(), TownHouseChangeInfo(), TrainConsistChanged(), UpdateCompanyRatingAndValue(), UpdateTownGrowRate(), VpSelectTilesWithMethod(), and Write_ValidateSetting().
static int32 ClampToI32 | ( | const int64 | a | ) | [inline, 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 164 of file math_func.hpp.
Referenced by UpdateCompanyRatingAndValue().
static uint16 ClampToU16 | ( | const uint64 | a | ) | [inline, static] |
Reduce an usigned 64-bit int to an unsigned 16-bit one.
a | The 64-bit value to clamp |
Definition at line 178 of file math_func.hpp.
Referenced by ExpandTown(), and TownGetVariable().
static uint ClampU | ( | const uint | a, | |
const uint | min, | |||
const uint | max | |||
) | [inline, 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 143 of file math_func.hpp.
Referenced by ChangeIndustryProduction(), CmdSetAutoReplace(), ConvertFromOldPlayerFace(), and Write_ValidateSetting().
static 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 190 of file math_func.hpp.
Referenced by DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Ufo(), DistanceManhattan(), DistanceMax(), DistanceMaxPlusManhattan(), DrawTileSelection(), NPFDistanceTrack(), PlaceTreeAtSameHeight(), and VpSelectTilesWithMethod().
static 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 206 of file math_func.hpp.
Referenced by DrawTileSelection(), FindWindowFromPt(), and GetProductionAroundTiles().
static 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).
a | The value to check | |
min | The minimum of the interval | |
max | The maximum of the interval |
Definition at line 221 of file math_func.hpp.
Referenced by AddChildSpriteToFoundation(), CmdBuildLongRoad(), CmdPlantTree(), CmdRemoveLongRoad(), DrawSmallMap(), GetClosestWaterDistance(), GetHalftileFoundationCorner(), IConsoleHistoryNavigate(), IsCompanyHQ(), IsNonContinuousFoundation(), IsSpecialRailFoundation(), IsValidCorner(), MarkTileDirty(), RemapOldStringID(), and TownAuthorityWndProc().
static 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 30 of file math_func.hpp.
Referenced by AddSortableSpriteToDraw(), AircraftController(), CalcHeightdiff(), CalcPercentVehicleFilled(), ChangeIndustryProduction(), CheckDifficultyLevels(), CheckTrainsLengths(), CmdDecreaseLoan(), CmdTerraformLand(), CommonRaiseLowerBigLand(), ConvertFromOldPlayerFace(), DistanceMax(), DrawChatMessage(), DrawGraph(), DrawVehicleInDepot(), EndVehicleMove(), GetAcceptanceAroundTiles(), GetGlobalVariable(), GetProductionAroundTiles(), GetStringBoundingBox(), GetTrainAcceleration(), GroupWndProc(), HeightMapCoastLines(), IndustryProductionCallback(), ini_load(), LocalAllocateWindow(), MarkViewportDirty(), PopupMainToolbMenu(), SanitizeSpriteOffset(), ScrollbarClickHandler(), SetSnowLine(), StationRatingMaxSorter(), TileLoop_Town(), UndrawChatMessage(), UpdateAircraftSpeed(), UpdateCompanyRatingAndValue(), and UpdateTownGrowRate().
static int min | ( | const int | a, | |
const int | b | |||
) | [inline, 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 59 of file math_func.hpp.
static 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 45 of file math_func.hpp.
Referenced by AddSortableSpriteToDraw(), AircraftController(), ApplyNoise(), CHashTableT< Titem_, Thash_bits_open_ >::CalcHash(), CalculateRefitMasks(), ChangeIndustryProduction(), CheckDifficultyLevels(), ChopLumberMillTrees(), CmdDecreaseLoan(), CmdGiveMoney(), CmdTerraformLand(), CommonRaiseLowerBigLand(), DeliverGoodsToIndustry(), DistanceFromEdge(), DrawCargoIcons(), DrawChatMessage(), EndVehicleMove(), FindStationsAroundIndustryTile(), GetAcceptanceAroundTiles(), GetAircraftFlyingAltitude(), GetCountAndDistanceOfClosestInstance(), GetIndustryTypeCount(), GetPCPElevation(), GetProductionAroundTiles(), GetTrainAcceleration(), GroupWndProc(), HeightMapCoastLines(), HeightMapGenerate(), HeightMapSmoothCoastInDirection(), HeightMapSmoothSlopes(), IConsoleCopyInParams(), IndustryGetVariable(), InitializeWindowsAndCaches(), LoadUnloadVehicle(), LocalAllocateWindow(), NewTrainPathfind(), NPFDistanceTrack(), PatchesSelectionWndProc(), CYapfDestinationTileT< Types >::PfCalcEstimate(), PlaceTree(), SaveToHighScore(), ScrollbarClickHandler(), TrainConsistChanged(), UndrawChatMessage(), UpdateAircraftSpeed(), UpdateCompanyRatingAndValue(), OldMemoryPoolBase::UpdateFirstFreeIndex(), UpdateStationAcceptance(), UpdateTownGrowRate(), and Write_ValidateSetting().
static uint minu | ( | const uint | a, | |
const uint | b | |||
) | [inline, 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 73 of file math_func.hpp.
Referenced by SlCalcNetStringLen(), and StationsWndShowStationRating().
void Swap | ( | T & | a, | |
T & | b | |||
) | [inline] |
Type safe swap operation.
a | variable to swap with b | |
b | variable to swap with a |
Definition at line 231 of file math_func.hpp.
Referenced by CalcHeightdiff(), CmdBuildBridge(), CmdBuildCanal(), CmdClearArea(), CmdConvertRail(), CmdLevelLand(), CmdPlantTree(), CmdRemoveFromRailroadStation(), DoDrawString(), GenerateDesertArea(), GenerateRockyArea(), and UpdateTileSelection().