OpenTTD Source 20241224-master-gf74b0cf984
|
Functions related to bit mathematics. More...
Go to the source code of this file.
Data Structures | |
struct | SetBitIterator< Tbitpos, Tbitset > |
Iterable ensemble of each set bit in a value. More... | |
struct | SetBitIterator< Tbitpos, Tbitset >::Iterator |
Macros | |
#define | SETBITS(x, y) ((x) |= (y)) |
Sets several bits in a variable. | |
#define | CLRBITS(x, y) ((x) &= ~(y)) |
Clears several bits in a variable. | |
Functions | |
template<typename T > | |
debug_inline static constexpr uint | GB (const T x, const uint8_t s, const uint8_t n) |
Fetch n bits from x, started at bit s. | |
template<typename T , typename U > | |
constexpr T | SB (T &x, const uint8_t s, const uint8_t n, const U d) |
Set n bits in x starting at bit s to d. | |
template<typename T , typename U > | |
constexpr T | AB (T &x, const uint8_t s, const uint8_t n, const U i) |
Add i to n bits of x starting at bit s. | |
template<typename T > | |
debug_inline constexpr bool | HasBit (const T x, const uint8_t y) |
Checks if a bit in a value is set. | |
template<typename T > | |
constexpr T | SetBit (T &x, const uint8_t y) |
Set a bit in a variable. | |
template<typename T > | |
constexpr T | ClrBit (T &x, const uint8_t y) |
Clears a bit in a variable. | |
template<typename T > | |
constexpr T | ToggleBit (T &x, const uint8_t y) |
Toggles a bit in a variable. | |
template<typename T > | |
constexpr T | AssignBit (T &x, const uint8_t y, bool value) |
Assigns a bit in a variable. | |
template<typename T > | |
constexpr uint8_t | FindFirstBit (T x) |
Search the first set bit in a value. | |
template<typename T > | |
constexpr uint8_t | FindLastBit (T x) |
Search the last set bit in a value. | |
template<typename T > | |
constexpr T | KillFirstBit (T value) |
Clear the first bit in an integer. | |
template<typename T > | |
constexpr uint | CountBits (T value) |
Counts the number of set bits in a variable. | |
template<typename T > | |
constexpr bool | HasExactlyOneBit (T value) |
Test whether value has exactly 1 bit set. | |
template<typename T > | |
constexpr bool | HasAtMostOneBit (T value) |
Test whether value has at most 1 bit set. | |
static uint32_t | BSWAP32 (uint32_t x) |
Perform a 32 bits endianness bitswap on x. | |
static uint16_t | BSWAP16 (uint16_t x) |
Perform a 16 bits endianness bitswap on x. | |
Functions related to bit mathematics.
Definition in file bitmath_func.hpp.
#define CLRBITS | ( | x, | |
y | |||
) | ((x) &= ~(y)) |
Clears several bits in a variable.
This macro clears several bits in a variable. The bits to clear are provided by a value. The new value is also returned.
x | The variable to clear some bits |
y | The value with set bits for clearing them in the variable |
Definition at line 166 of file bitmath_func.hpp.
#define SETBITS | ( | x, | |
y | |||
) | ((x) |= (y)) |
Sets several bits in a variable.
This macro sets several bits in a variable. The bits to set are provided by a value. The new value is also returned.
x | The variable to set some bits |
y | The value with set bits for setting them in the variable |
Definition at line 136 of file bitmath_func.hpp.
|
constexpr |
Add i to n bits of x starting at bit s.
This adds the value of i on n bits of x starting at bit s. The parameters x, s, i are similar to GB. Besides, \ a x must be a variable as the result are saved there. An overflow does not affect the following bits of the given bit window and is simply ignored.
x | The variable to add some bits at some position |
s | The start position of the addition |
n | The size/window for the addition |
i | The value to add at the given start position in the given window. |
Definition at line 83 of file bitmath_func.hpp.
Referenced by IncHouseConstructionTick(), and IncreaseRoadWorksCounter().
|
constexpr |
Assigns a bit in a variable.
This function assigns a single bit in a variable. The variable is changed and the value is also returned. Parameter y defines the bit to assign and starts at the LSB with 0.
x | The variable to assign the bit |
y | The bit position to assign |
value | The new bit value |
Definition at line 200 of file bitmath_func.hpp.
Referenced by AfterLoadGame(), AircraftVehicleChangeInfo(), CmdSetCompanyColour(), CmdSetGroupLivery(), CmdSetVehicleVisibility(), GuiGroupListAddChildren(), VehicleOrderSaver::Restore(), SetCrossingBarred(), SetCrossingReservation(), SetDepotReservation(), SetDockingTile(), SetHasSignals(), SetNonFloodingWaterTile(), SetRailStationReservation(), SetStationTileBlocked(), SetStationTileHavePylons(), SetStationTileHaveWires(), SetTrackReservation(), Order::SetTravelTimetabled(), SetTunnelBridgeReservation(), and Order::SetWaitTimetabled().
|
inlinestatic |
Perform a 16 bits endianness bitswap on x.
x | the variable to bitswap |
Definition at line 379 of file bitmath_func.hpp.
|
inlinestatic |
Perform a 32 bits endianness bitswap on x.
x | the variable to bitswap |
Definition at line 364 of file bitmath_func.hpp.
Referenced by AddGrfInfo(), CargoChangeInfo(), NewGRFInspectWindow::DrawMainPanelWidget(), FormatLabel(), GetNewEngine(), NewGRFProfiler::GetOutputFilename(), ContentInfo::GetTextfile(), GraphicsSetLoadConfig(), GraphicsSetSaveConfig(), HandleNode(), HandleSavegameLoadCrash(), HasGRFConfig(), IsGoodGRFConfigList(), LoadNewGRF(), LoadTranslationTable(), MakePNGImage(), ObjectChangeInfo(), PickerSaveConfig(), RailTypeChangeInfo(), ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(), RoadTypeChangeInfo(), SetNewGRFOverride(), ShowMissingContentWindow(), SlCopyInternal(), StationChangeInfo(), SurveyGrfs(), BasePersistentStorageArray::SwitchMode(), and TranslateGRFStrings().
|
constexpr |
Clears a bit in a variable.
This function clears a bit in a variable. The variable is changed and the value is also returned. Parameter y defines the bit to clear and starts at the LSB with 0.
x | The variable to clear the bit |
y | The bit position to clear |
Definition at line 151 of file bitmath_func.hpp.
Referenced by AfterLoadGame(), AircraftController(), AircraftHandleDestTooFar(), RoadStop::AllocateBay(), RoadStop::AllocateDriveThroughBay(), AllocateRoadType(), Vehicle::BeginLoading(), CalculateRefitMasks(), CargoChangeInfo(), ChangeOwnershipOfCompanyItems(), GroundVehicle< T, Type >::ClearArticulatedPart(), RoadStop::ClearDriveThrough(), GroundVehicle< T, Type >::ClearEngine(), GroundVehicle< T, Type >::ClearFreeWagon(), GroundVehicle< T, Type >::ClearFrontEngine(), GroundVehicle< T, Type >::ClearMultiheaded(), ClearSingleBridgeMiddle(), ClearSnow(), ClearTownHouse(), GroundVehicle< T, Type >::ClearWagon(), CmdAutofillTimetable(), CmdSetTimetableStart(), CmdTownGrowthRate(), Train::ConsistChanged(), ConvertOldMultiheadToNew(), CopyGRFConfigList(), GroundVehicle< T, Type >::Crash(), DEFINE_POOL_METHOD(), Vehicle::DeleteUnreachedImplicitOrders(), DisableEngineForCompany(), DispatchLeftClickEvent(), DrawRailCatenaryRailway(), FeatureTownName(), GenerateStationName(), Vehicle::HandlePathfindingResult(), LoadNewGRF(), LoadUnloadVehicle(), RoadStop::MakeDriveThrough(), MapSpriteMappingRecolour(), PickerWindow::OnClick(), SelectCompanyLiveryWindow::OnInvalidateData(), OpenBankFile(), ParamSet(), PrepareToEnterBridge(), PrepareUnload(), ReadSpriteLayout(), ReadSpriteLayoutSprite(), ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN_SECURE(), LinkRefresher::RefreshLinks(), FreeUnitIDGenerator::ReleaseID(), RemoveFirstTrack(), RemoveFirstTrackdir(), ReverseTrainDirection(), SetGroupFlag(), StationHandleBigTick(), SwapTrainFlags(), ToggleInvisibilityWithTransparency(), TryPathReserve(), UpdateTownGrowth(), UpdateVehicleTimetable(), GroundVehicle< T, Type >::UpdateZPositionAndInclination(), and VehicleEnterDepot().
|
constexpr |
Counts the number of set bits in a variable.
value | the value to count the number of bits in. |
Definition at line 262 of file bitmath_func.hpp.
Referenced by CalculateCompanyAssetValue(), CheckFlatLandRoadStop(), CmdBuildRoad(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdConvertRail(), CmdConvertRoad(), CmdGoalQuestion(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DrawRoadTypeCatenary(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), CYapfFollowShipT< Types >::GetRandomTrackdir(), RemoveGenericRoadStop(), RemoveRoad(), CompanyStationsWindow::SetStringParameters(), ShowRefitOptionsList(), TownGenerateCargoBinominal(), and UpdateCompanyRatingAndValue().
|
constexpr |
Search the first set bit in a value.
When no bit is set, it returns 0.
x | The value to search. |
Definition at line 213 of file bitmath_func.hpp.
Referenced by CYapfBaseT< Types >::AddMultipleNodes(), Map::Allocate(), CalculateRefitMasks(), ExploreSegment(), HousePickerCallbacks::FillUsedItems(), FindFirstTrack(), FindFirstTrackdir(), GenerateStationName(), FreeUnitIDGenerator::NextID(), CYapfCostRoadT< Types >::PfCalcCost(), CYapfCostRailT< Types >::PfCalcCost(), CYapfOriginTileT< Types >::PfSetStartupNodes(), RemoveFirstTrack(), RemoveFirstTrackdir(), RoadFindPathToDest(), CompanyStationsWindow::SetStringParameters(), TrackBitsToTrack(), TrainController(), HousePickerCallbacks::UpdateSavedItems(), and YapfRoadVehicleChooseTrack().
|
constexpr |
Search the last set bit in a value.
When no bit is set, it returns 0.
x | The value to search. |
Definition at line 232 of file bitmath_func.hpp.
|
staticconstexpr |
Fetch n bits from x, started at bit s.
This function can be used to fetch n bits from the value x. The s value set the start position to read. The start position is count from the LSB and starts at 0
. The result starts at a LSB, as this isn't just an and-bitmask but also some bit-shifting operations. GB(0xFF, 2, 1) will so return 0x01 (0000 0001) instead of 0x04 (0000 0100).
x | The value to read some bits. |
s | The start position to read some bits. |
n | The number of bits to read. |
Definition at line 32 of file bitmath_func.hpp.
Referenced by AddAcceptedCargoOfHouse(), AfterLoadGame(), AirportChangeInfo(), AmbientSoundEffectCallback(), AnimationBase< Tbase, Tspec, Tobj, Textra, GetCallback, Tframehelper >::AnimateTile(), Buffer::AppendUtf8(), AreCompanyManagerFaceBitsValid(), BmpRead1(), BmpRead24(), BmpRead4(), BmpRead4Rle(), BmpRead8(), BuildObject(), BuildTownHouse(), AnimationBase< Tbase, Tspec, Tobj, Textra, GetCallback, Tframehelper >::ChangeAnimationFrame(), ChangeIndustryProduction(), ChangeTrainDirRandomly(), CheckPartialPixelZ(), CmdBuildAirport(), CmdBuildIndustry(), CmdBuildObject(), CmdBuildObjectArea(), CmdBuildRailStation(), CmdBuildRoadStop(), CmdClearArea(), CmdLandscapeClear(), CmdLevelLand(), CmdPlantTree(), CmdStartStopVehicle(), CmdTerraformLand(), Convert8bitBooleanCallback(), ConvertFromOldCompanyManagerFace(), Blitter_32bppAnim::CopyFromBuffer(), CopyFromOldName(), CreateNewIndustry(), DecodeMonitorCargoType(), DecodeMonitorCompany(), DecodeMonitorIndustry(), DecodeMonitorTown(), Disaster_CoalMine_Init(), DisasterTick_Aircraft(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Submarine(), DisasterTick_Zeppeliner(), DoCreateNewIndustry(), Blitter_32bppOptimized::Draw(), Blitter_40bppAnim::Draw(), DrawCommonTileSeq(), DrawCommonTileSeqInGUI(), DrawMatrix(), DrawNewHouseTileInGUI(), DrawNewObjectTileInGUI(), DrawRoadStopTile(), DrawSprite(), DrawSpriteToRgbaBuffer(), DrawSpriteViewport(), DrawTileLayout(), AIInfo::DummyConstructor(), FeatureTownName(), UnmappedChoiceList::Flush(), FormatLabel(), FormatString(), AI::GameLoop(), GenerateCompanyColour(), GenerateLandscape(), GenerateTrees(), GenRandomRoadBits(), GetAiPurchaseCallbackResult(), GetAnimatedTileState(), GetBridgeAxis(), GetBridgeType(), GetCargoSuffix(), GetCleanHouseType(), GetCleanIndustryGfx(), GetClearCounter(), GetClearDensity(), StoryPageButtonData::GetColour(), GetCompanyManagerFaceBits(), GetCompanyManagerFaceSprite(), Order::GetConditionComparator(), Order::GetConditionValue(), Order::GetConditionVariable(), GetCountAndDistanceOfClosestInstance(), GetCrossingRoadAxis(), StoryPageButtonData::GetCursor(), GetCustomRoadStopSpecIndex(), Order::GetDepotActionType(), Order::GetDepotOrderType(), GetDisallowedRoadDirections(), GetDistanceFromNearbyHouse(), GetFeatureIndex(), GetFeatureNum(), GetFence(), GetFieldType(), GetGlobalVariable(), GetHouseBuildingStage(), GetHouseConstructionTick(), BuildHouseWindow::GetHouseInformation(), GetHouseProcessingTime(), GetHouseTriggers(), GetIndustryConstructionCounter(), GetIndustryConstructionStage(), GetIndustryTriggers(), GetLiftDestination(), GetLiftPosition(), GetLoadAmount(), Order::GetLoadType(), GetLockDirection(), GetLockPart(), GetNearbyTile(), Waypoint::GetNewGRFVariable(), GetNextArticulatedPart(), Order::GetNonStopType(), GetPresentSignals(), GetRailDepotDirection(), GetRailReservationTrackBits(), GetRailTileType(), GetRailType(), RailTypeScopeResolver::GetRandomBits(), RoadTypeScopeResolver::GetRandomBits(), GetRawClearGround(), GetRefitCostFactor(), GetRoadBits(), GetRoadDepotDirection(), GetRoadOwner(), GetRoadside(), GetRoadTileType(), GetRoadWaypointRoadside(), VehicleResolverObject::GetScope(), GetShipDepotAxis(), GetShipDepotPart(), GetSignalStates(), GetStationTileRandomBits(), GetStationType(), Order::GetStopLocation(), GetSurname(), GetTileOwner(), GetTileType(), GetTrackBits(), GetTreeCount(), GetTreeDensity(), GetTreeGround(), GetTreeGrowth(), GetTropicZone(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), Order::GetType(), Order::GetUnloadType(), GRFConfig::GetValue(), GetVarFileType(), VehicleScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), StationScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), GetVarMemType(), StoryPageButtonData::GetVehicleType(), GetWaterClass(), GetWaterTileType(), GfxFillPolygon(), GfxFillRect(), GlobalVarChangeInfo(), HandleAutoSignalPlacement(), HandleCrashedAircraft(), HandleCrashedTrain(), RoadStop::HasFreeBay(), HeightMapNormalize(), IncHouseConstructionTick(), IncreaseRoadWorksCounter(), IndustriesChangeInfo(), IndustrytilesChangeInfo(), IsBridgeAbove(), IsCustomRoadStopSpecIndex(), IsWaypointClass(), IsWaypointClass(), MAPEChunkHandler::Load(), ORDRChunkHandler::Load(), VEHSChunkHandler::Load(), LoadChunk(), MakeCzechTownName(), MapNewGRFIndustryType(), Order::MapOldOrder(), MaybeCrashAirplane(), MirrorRoadBits(), MoveWaypointsToBaseStations(), ObjectChangeInfo(), OrdersWindow::OnInvalidateData(), TimetableWindow::OnInvalidateData(), VehicleListWindow::OnInvalidateData(), OpenBankFile(), Blitter_32bppAnim::PaletteAnimate(), ParamSet(), PlaceTree(), PlaceTreeAtSameHeight(), PlaceTreeGroups(), Packet::PrepareToSend(), ReadSpriteLayoutSprite(), OpenGLBackend::RenderOglSprite(), ResetRestoreAllTransparency(), DeterministicSpriteGroup::Resolve(), RotateRoadBits(), ScaleAllCompanyManagerFaceBits(), SeedChance(), Packet::Send_uint16(), Packet::Send_uint32(), Packet::Send_uint64(), SetIndustryGfx(), BuildObjectWindow::SetStringParameters(), SetWaterClassDependingOnSurroundings(), Vehicle::ShowVisualEffect(), SpawnAdvancedVisualEffect(), StartTextRefStackUsage(), StartupOneEngine(), TileHash2Bit(), TileLoop_Town(), TownGenerateCargoOriginal(), TownHouseChangeInfo(), TrainCheckIfLineEnds(), TranslateTTDPatchCodes(), TryBuildLightHouse(), VehicleListIdentifier::UnpackIfValid(), UnpackVersion4Order(), UpdateCursorSize(), Vehicle::UpdateVisualEffect(), Utf8Decode(), Utf8Encode(), Utf8EncodedCharLen(), StoryPageButtonData::ValidateColour(), StoryPageButtonData::ValidateCursor(), StoryPageButtonData::ValidateVehicleType(), VehicleFromPos(), VehicleFromPosXY(), EndianBufferWriter< Tcont, Titer >::Write(), and LanguageWriter::WriteLang().
|
constexpr |
Test whether value has at most 1 bit set.
value | the value to test. |
Definition at line 290 of file bitmath_func.hpp.
Referenced by DrawRoadBits(), ExploreSegment(), GetNewCargoTypeForReplace(), MaskWireBits(), Vehicle::NeedsServicing(), and ShowRefitOptionsList().
|
constexpr |
Checks if a bit in a value is set.
This function checks if a bit inside a value is set or not. The y value specific the position of the bit, started at the LSB and count from 0
.
x | The value to check |
y | The position of the bit to check, started from the LSB |
Definition at line 103 of file bitmath_func.hpp.
Referenced by AddAcceptedCargoOfHouse(), AddArticulatedParts(), NewGRFWindow::AddGRFToActive(), LinkGraph::AddNode(), AfterLoadGame(), AfterLoadGRFs(), AfterLoadRoadStops(), AircraftHandleDestTooFar(), AircraftVehicleChangeInfo(), RoadStop::AllocateBay(), AnimationBase< Tbase, Tspec, Tobj, Textra, GetCallback, Tframehelper >::AnimateTile(), Vehicle::BeginLoading(), TimetableWindow::BuildArrivalDepartureList(), BaseVehicleListWindow::BuildCargoDropDownList(), GameOptionsWindow::BuildDropDownList(), BuildObject(), PickerWindow::BuildPickerClassList(), PickerWindow::BuildPickerTypeList(), RefitWindow::BuildRefitList(), BuildReplacementVehicle(), CompanyStationsWindow::BuildStationsList(), CalcPercentVehicleFilled(), CalculateRefitMasks(), CanBuildVehicleInfrastructure(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CanStationTileHavePylons(), CanStationTileHaveWires(), CargoAndEngineFilter(), CargoesField::CargoClickedAt(), CcRoadStop(), ChangeIndustryProduction(), ChangeOwnershipOfCompanyItems(), CheckAutoreplaceValidity(), CheckBuildableTile(), CheckClickOnViewportSign(), CheckFlatLandRailStation(), CheckIfIndustryTilesAreFree(), CheckIfIndustryTileSlopes(), RoadStop::Entry::CheckIntegrity(), CheckRoadBlockedForOvertaking(), BuildRailStationWindow::CheckSelectedSize(), ChooseShipTrack(), RoadStop::ClearDriveThrough(), CmdAlterGroup(), CmdAutoreplaceVehicle(), CmdBuildObject(), CmdBuildRailStation(), CmdBuildRailWaypoint(), CmdBuildRoad(), CmdBuildRoadStop(), CmdBuildRoadWaypoint(), CmdBuildSingleRail(), CmdBuildSingleSignal(), CmdBuyCompany(), CmdCloneVehicle(), CmdDoTownAction(), CmdForceTrainProceed(), CmdReverseTrainDirection(), CmdSetVehicleOnTime(), CmdSignalTrackHelper(), CmdStartStopVehicle(), CompaniesGenStatistics(), CargoesField::ConnectCargo(), CargoesRow::ConnectIndustryAccepted(), CargoesRow::ConnectIndustryProduced(), Train::ConsistChanged(), ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), BaseConsist::CopyConsistPropertiesFrom(), CountArticulatedParts(), Train::Crash(), NetworkAuthenticationServerHandler::Create(), CreateGroupFromGroupID(), CreateNewIndustryHelper(), Vehicle::DeleteUnreachedImplicitOrders(), DeliverGoods(), Engine::DetermineCapacity(), DisasterTick_Aircraft(), DisasterTick_Helicopter_Rotors(), DisasterTick_Submarine(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), DispatchLeftClickEvent(), DoCreateNewIndustry(), NWidgetScrollbar::Draw(), BaseSettingEntry::Draw(), CargoesField::Draw(), TownAuthorityWindow::DrawActions(), TimetableWindow::DrawArrivalDeparturePanel(), DrawBridgeMiddle(), DrawCanalWater(), DrawCommonTileSeq(), DrawCommonTileSeqInGUI(), DrawCompanyManagerFace(), DrawEngineList(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), IndustryViewWindow::DrawInfo(), NewGRFInspectWindow::DrawMainPanelWidget(), DrawNewHouseTileInGUI(), DrawRailCatenaryOnBridge(), DrawRailCatenaryRailway(), TownAuthorityWindow::DrawRatings(), DrawRoadBits(), DrawRoadDepotSprite(), DrawRoadStopTile(), DrawSprite(), DrawSpriteViewport(), DrawStationTile(), TimetableWindow::DrawSummaryPanel(), DrawTile_Road(), RoadStopPickerCallbacks< roadstoptype >::DrawType(), BaseVehicleListWindow::DrawVehicleListItems(), DrawWaterLock(), SelectCompanyLiveryWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), PaymentRatesGraphWindow::DrawWidget(), IndustryProductionGraphWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TransparenciesWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), EngineReplacement(), ErrorUnknownCallbackResult(), FeatureTownName(), FillGRFDetails(), FillNewGRFVehicleCache(), WaypointPickerCallbacks::FillUsedItems(), RoadWaypointPickerCallbacks::FillUsedItems(), SignList::FilterSignList(), FinaliseEngineArray(), FinalisePriceBaseMultipliers(), FindDeletedWaypointCloseTo(), FindGRFConfig(), FindJoiningWaypoint(), FindTrainOnTrackEnum(), FixOwnerOfRailTrack(), FixTTOEngines(), FormatString(), GenerateStationName(), Train::GetAccelerationStatus(), GetAcceptanceMask(), GetArticulatedRefitMasks(), GetBestFittingSubType(), GetCanalSpriteOffset(), GetCapacityOfArticulatedParts(), GetCargoSubtypeText(), GetCargoSuffix(), GetCargoTypesOfArticulatedParts(), HousePickerCallbacks::GetClassName(), GetCompanyRailTypes(), GetCompanyRoadTypes(), Train::GetDisplayImageWidth(), GetEngineLiveryScheme(), RoadStop::GetEntry(), RoadStop::GetEntry(), GetFoundation_Town(), GetGlobalVariable(), GetIfStopIsForType(), Train::GetImage(), GetIncompatibleRefitOrderIdForAutoreplace(), GetIndustryProbabilityCallback(), GetLoadAmount(), GetMaskOfTownActions(), Train::GetMaxWeight(), GetNewCargoTypeForReplace(), GetNextArticulatedPart(), Airport::GetNumHangars(), NewGRFWindow::GetPalette(), Train::GetPoweredPartPower(), GetPreviewCompany(), GetRailReservationTrackBits(), GetRailStationAxis(), GetRailTypeDropDownList(), GetRailTypes(), GetRefitCostFactor(), GetRoadTypes(), GetSingleSignalState(), GroundVehicle< T, Type >::GetSlopeResistance(), GetTLG(), CompanyInfrastructureWindow::GetTotalMaintenanceCost(), GetTownRoadType(), GetTownRoadTypeFirstIntroductionDate(), HousePickerCallbacks::GetTypeName(), BaseGraphWindow::GetValuesInterval(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), StationScopeResolver::GetVariable(), Train::GetWeight(), GRFLoadConfig(), GroundSpritePaletteTransform(), HandleBankruptcyTakeover(), Vehicle::HandleBreakdown(), Vehicle::HandleLoading(), Vehicle::HandlePathfindingResult(), LinkRefresher::HandleRefit(), HandleSavegameLoadCrash(), HandleScrollbarScrolling(), HasCPUIDFlag(), HasCrossingReservation(), HasDepotReservation(), HasGrfMiscBit(), HasPowerOnRail(), HasPowerOnRoad(), HasRailCatenary(), HasRailTypeAvail(), GoodsEntry::HasRating(), HasRoadCatenary(), HasRoadTypeAvail(), HasStationReservation(), HasTrack(), HasTrack(), HasTrackdir(), HasTunnelBridgeReservation(), HasTunnelBridgeSnowOrDesert(), HeightMapCoastLines(), HeightMapCurves(), HeightMapSmoothCoasts(), IndustryTemporarilyRefusesCargo(), InitRailTypes(), InitRoadTypes(), IsArticulatedEngine(), Vehicle::IsArticulatedPart(), IsArticulatedVehicleRefittable(), IsBridge(), IsCompatibleRail(), IsCrossingBarred(), NWidgetCore::IsDisabled(), IsDockingTile(), Engine::IsEnabled(), GroundVehicle< T, Type >::IsEngine(), IsEngineBuildable(), IsEngineRefittable(), RoadStop::IsEntranceBusy(), ObjectSpec::IsEverAvailable(), RoadStop::IsFreeBay(), GroundVehicle< T, Type >::IsFreeWagon(), Vehicle::IsFrontEngine(), IsGoodGRFConfigList(), Engine::IsHidden(), NWidgetCore::IsHighlighted(), IsHouseCompleted(), IsIndustryCompleted(), IsInvisibilitySet(), IsLoggableGrfConfig(), NWidgetCore::IsLowered(), GroundVehicle< T, Type >::IsMultiheaded(), IsNonFloodingWaterTile(), IsOnSnow(), IsRoadStopAvailable(), IsRoadWaypointOnSnowOrDesert(), IsSignalPresent(), IsSnowTile(), IsStationAvailable(), IsStationTileBlocked(), IsTransparencySet(), Order::IsTravelTimetabled(), IsTunnel(), IsUphillTrackdir(), IsValidCompanyManagerFace(), GroundVehicle< T, Type >::IsWagon(), Order::IsWaitTimetabled(), RoadStop::Leave(), LiftHasDestination(), LoadNewGRF(), LoadNewGRFFile(), LoadUnloadVehicle(), MakeDefaultName(), MapNewGRFIndustryType(), MapSpriteMappingRecolour(), MarkTrainAsStuck(), MonitorMonitorsIndustry(), MoveWaypointsToBaseStations(), Vehicle::NeedsServicing(), NetworkAfterNewGRFScan(), NetworkAutoCleanCompanies(), NewVehicleAvailable(), ReplaceVehicleWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), VehicleGroupWindow::OnClick(), NewGRFWindow::OnClick(), OskWindow::OnClick(), PickerWindow::OnClick(), BuildRailStationWindow::OnClick(), BuildRoadStationWindow::OnClick(), TimetableWindow::OnClick(), TownAuthorityWindow::OnClick(), SelectCompanyLiveryWindow::OnDropdownSelect(), SelectCompanyLiveryWindow::OnInvalidateData(), GenerateLandscapeWindow::OnInvalidateData(), NewGRFWindow::OnInvalidateData(), PickerWindow::OnInvalidateData(), TimetableWindow::OnInvalidateData(), TownAuthorityWindow::OnInvalidateData(), VehicleListWindow::OnInvalidateData(), SelectCompanyManagerFaceWindow::OnPaint(), VehicleGroupWindow::OnPaint(), BuildRailStationWindow::OnPaint(), TimetableWindow::OnPaint(), TownAuthorityWindow::OnPaint(), OpenBankFile(), SignList::OwnerVisibilityFilter(), ParamSet(), PerformStationTileSlopeCheck(), PlayVehicleSound(), PopupMainCompanyToolbMenu(), LinkRefresher::PredictNextOrder(), NewGRFSpriteLayout::PrepareLayout(), PrepareToEnterBridge(), PrepareUnload(), NewGRFSpriteLayout::ProcessRegisters(), PropagateChildLivery(), Rail90DegTurnDisallowed(), RailNoLevelCrossings(), RailVehicleChangeInfo(), RandomCompanyManagerFaceBits(), ReadSpriteLayout(), ReadSpriteLayoutSprite(), RoadStop::Entry::Rebuild(), LinkGraphOverlay::RebuildCache(), RefitVehicle(), LinkRefresher::RefreshLinks(), ResetIndustries(), StationResolverObject::ResolveReal(), ReverseTrainDirection(), RoadFindPathToDest(), RoadNoLevelCrossing(), RoadTypesAllowHouseHere(), RoadVehicleChangeInfo(), RunEconomyVehicleDayProc(), NGRFChunkHandler::Save(), ScaleAllCompanyManagerFaceBits(), ServerNetworkGameSocketHandler::SendNewGRFCheck(), Vehicle::SendToDepot(), BuildVehicleWindow::SetCargoFilterArray(), LinkGraphLegendWindow::SetOverlay(), ReplaceVehicleWindow::SetStringParameters(), SelectCompanyLiveryWindow::SetStringParameters(), GenerateLandscapeWindow::SetStringParameters(), BuildObjectWindow::SetStringParameters(), SetYearEngineAgingStops(), ShipVehicleChangeInfo(), ShowDropDownMenu(), ShowMissingContentWindow(), ShowNewGrfVehicleError(), Vehicle::ShowVisualEffect(), SlReadSimpleGamma(), SpawnAdvancedVisualEffect(), SpriteLayoutPaletteTransform(), StartupOneEngine(), StationChangeInfo(), SubtractMoneyFromAnyCompany(), SurveyGrfs(), SwapTrainFlags(), SwitchNewGRFBlitter(), TileLoop_Town(), TileLoop_Water(), ToolbarOptionsClick(), TownCanGrowRoad(), TownDirectoryWindow::TownRatingSorter(), TownTickHandler(), TrackOverlapsTracks(), TrainController(), TriggerIndustryProduction(), TriggerObjectAnimation(), TriggerObjectTileAnimation(), TriggerRoadStopRandomisation(), TriggerStationRandomisation(), TriggerWatchedCargoCallbacks(), TryBuildTownHouse(), TryPathReserve(), OrdersWindow::UpdateAutoRefitState(), UpdateCompanyGroupLiveries(), UpdateCompanyLiveries(), Train::UpdateDeltaXY(), UpdateObjectColours(), OskWindow::UpdateOskState(), UpdateTownGrowth(), UpdateTownGrowthRate(), UpdateVehicleTimetable(), Vehicle::UpdateVisualEffect(), CompanyInfrastructureWindow::UpdateWidgetSize(), GroundVehicle< T, Type >::UpdateZPosition(), IndustrySpec::UsesOriginalEconomy(), Utf8Decode(), VehicleExitDir(), VehicleLengthChanged(), VerifyAutoreplaceRefitForOrders(), VisitAdjacentWaterRegionPatchNeighbors(), WaypointWindow::WaypointWindow(), and RoadStop::~RoadStop().
|
constexpr |
Test whether value has exactly 1 bit set.
value | the value to test. |
Definition at line 278 of file bitmath_func.hpp.
Referenced by CheckFlatLandRoadStop(), CheckRoadSlope(), CmdBuildRoad(), and CmdBuildSingleRail().
|
constexpr |
Clear the first bit in an integer.
This function returns a value where the first bit (from LSB) is cleared. So, 110100 returns 110000, 000001 returns 000000, etc.
value | The value to clear the first bit |
Definition at line 250 of file bitmath_func.hpp.
Referenced by CYapfBaseT< Types >::AddMultipleNodes(), CheckAllowRemoveRoad(), CheckNextTrainTile(), CmdBuildSingleSignal(), ExtendTrainReservation(), IsSafeWaitingPosition(), CYapfCostRoadT< Types >::PfCalcCost(), CYapfCostRailT< Types >::PfCalcCost(), CYapfOriginTileT< Types >::PfSetStartupNodes(), RoadFindPathToDest(), TrackBitsToTrack(), and TracksOverlap().
|
constexpr |
Set n bits in x starting at bit s to d.
This function sets n bits from x which started as bit s to the value of d. The parameters x, s and n works the same as the parameters of GB. The result is saved in x again. Unused bits in the window provided by n are set to 0 if the value of d isn't "big" enough. This is not a bug, its a feature.
x | The variable to change some bits |
s | The start position for the new bits |
n | The size/window for the new bits |
d | The actually new bits to save in the defined position. |
Definition at line 58 of file bitmath_func.hpp.
Referenced by AfterLoadGame(), AircraftVehicleChangeInfo(), ClearEnginesHiddenFlagOfCompany(), EncodeCargoIndustryMonitor(), EncodeCargoTownMonitor(), RoadStop::Enter(), FixOwnerOfRailTrack(), GetGlobalVariable(), GetPlatformInfo(), GUIEngineListAddChildren(), HaltLift(), IndustriesChangeInfo(), IndustryProductionCallback(), LoadUnloadVehicle(), MakeBridgeRamp(), MakeField(), MakeLockTile(), MakeObject(), MakeRailDepot(), MakeRailTunnel(), MakeRoadCrossing(), MakeRoadDepot(), MakeRoadNormal(), MakeRoadTunnel(), MakeShipDepot(), MakeShore(), MakeStation(), MakeTree(), MakeWater(), MoveBuoysToWaypoints(), RailVehicleChangeInfo(), ReadSpriteLayoutSprite(), ResetIndustryConstructionStage(), RoadVehicleChangeInfo(), SetAnimatedTileState(), SetClearCounter(), SetClearDensity(), StoryPageButtonData::SetColour(), SetCompanyManagerFaceBits(), Order::SetConditionComparator(), Order::SetConditionValue(), Order::SetConditionVariable(), StoryPageButtonData::SetCursor(), SetCustomRoadStopSpecIndex(), Order::SetDepotActionType(), Order::SetDepotOrderType(), SetDisallowedRoadDirections(), RoadStop::SetEntranceBusy(), SetFence(), SetFieldType(), SetHouseCompleted(), SetHouseProcessingTime(), SetHouseTriggers(), SetHouseType(), SetIndustryConstructionCounter(), SetIndustryConstructionStage(), SetIndustryGfx(), SetIndustryTriggers(), SetLiftDestination(), SetLiftPosition(), Order::SetLoadType(), Order::SetNonStopType(), SetPresentSignals(), SetRailDepotExitDirection(), SetRailType(), SetRoadBits(), SetRoadDepotExitDirection(), SetRoadOwner(), SetRoadside(), SetRoadTypeRoad(), SetRoadTypeTram(), SetRoadWaypointRoadside(), SetSignalStates(), SetStationTileRandomBits(), Order::SetStopLocation(), GRFConfig::SetSuitablePalette(), SetTileOwner(), SetTileType(), SetTrackBits(), SetTrackReservation(), SetTreeGroundDensity(), SetTreeGrowth(), SetTropicZone(), SetTunnelBridgeSnowOrDesert(), Order::SetUnloadType(), GRFConfig::SetValue(), StoryPageButtonData::SetVehicleType(), SetWaterClass(), SetWaterTileType(), ShipVehicleChangeInfo(), TerminateRoadWorks(), TownHouseChangeInfo(), UpdateStationAcceptance(), Vehicle::UpdateVisualEffect(), and VerifyOldNameChecksum().
|
constexpr |
Set a bit in a variable.
This function sets a bit in a variable. The variable is changed and the value is also returned. Parameter y defines the bit and starts at the LSB with 0.
x | The variable to set a bit |
y | The bit position to set |
Definition at line 121 of file bitmath_func.hpp.
Referenced by AddAcceptedCargoSetMask(), AddArticulatedParts(), AddChildSpriteScreen(), AddSortableSpriteToDraw(), AfterLoadGame(), AircraftController(), AircraftHandleDestTooFar(), AircraftVehicleChangeInfo(), AllocateRoadType(), BuildStationPart(), CalculateRefitMasks(), CalculateRoadStopCost(), CargoChangeInfo(), ChangeOwnershipOfCompanyItems(), ChangeTownRating(), CheckConsistencyOfArticulatedVehicle(), CheckIfTrainNeedsService(), RoadStop::ClearDriveThrough(), DropdownWindow::Close(), CmdAutofillTimetable(), CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRailWagon(), CmdBuildRoadVehicle(), CmdBuildRoadWaypoint(), CmdBuildShip(), CmdCloneVehicle(), CmdCreateGroup(), CmdSignalTrackHelper(), CmdTownGrowthRate(), CargoesField::ConnectCargo(), Train::ConsistChanged(), ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), BaseConsist::CopyConsistPropertiesFrom(), CopyGRFConfigList(), DEFINE_POOL_METHOD(), DeliverGoods(), DisplayVehicleSortDropDown(), SettingsPage::Draw(), DrawCommonTileSeq(), DrawRailCatenaryRailway(), DrawStationCoverageAreaText(), DrawTile_Road(), BaseVehicleListWindow::DrawVehicleListItems(), EnableEngineForCompany(), EncodeCargoIndustryMonitor(), RoadStop::Enter(), ErrorUnknownCallbackResult(), FinaliseEngineArray(), WaterRegion::ForceUpdate(), RoadStop::FreeBay(), GetAcceptanceMask(), GetAvailableVehicleCargoTypes(), GetCargoTypesOfArticulatedParts(), GetCargoTypesOfArticulatedVehicle(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetCountAndDistanceOfClosestInstance(), GetEmptyMask(), GetGlobalVariable(), GetMaskOfAllowedCurrencies(), Airport::GetNumHangars(), GetPresentRoadTypes(), GetRailTypes(), GetRoadTypes(), HouseScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), StationScopeResolver::GetVariable(), GRFLoadConfig(), GRFUnsafe(), HandleBankruptcyTakeover(), Vehicle::HandlePathfindingResult(), InitializeSortedCargoSpecs(), InitRailTypes(), InitRoadTypes(), InsertOrder(), IsEngineRefittable(), IsGoodGRFConfigList(), Vehicle::LeaveStation(), LoadNewGRF(), LoadUnloadVehicle(), LookupManyOfMany(), MakeDefaultName(), RoadStop::MakeDriveThrough(), MakeSnow(), Order::MapOldOrder(), MapSpriteMappingRecolour(), MarkTrainAsStuck(), NetworkAutoCleanCompanies(), GenerateLandscapeWindow::OnClick(), PaymentRatesGraphWindow::OnClick(), IndustryProductionGraphWindow::OnClick(), PickerWindow::OnClick(), GraphLegendWindow::OnInvalidateData(), ParamSet(), LinkRefresher::PredictNextOrder(), NewGRFSpriteLayout::PrepareLayout(), PrepareUnload(), RailTypeChangeInfo(), RailVehicleChangeInfo(), ReadGRFSpriteOffsets(), ReadSpriteLayoutSprite(), LinkRefresher::RefreshLinks(), RoadTypeChangeInfo(), RoadVehicleChangeInfo(), ScrollbarClickPositioning(), Vehicle::SendToDepot(), GroundVehicle< T, Type >::SetArticulatedPart(), SetBridgeMiddle(), HousePickerCallbacks::SetClimateMask(), GroundVehicle< T, Type >::SetEngine(), GroundVehicle< T, Type >::SetFreeWagon(), GroundVehicle< T, Type >::SetFrontEngine(), SetGroupFlag(), SetIndustryCompleted(), SetLiftDestination(), GroundVehicle< T, Type >::SetMultiheaded(), SmallMapWindow::SetOverlayCargoMask(), GroundVehicle< T, Type >::SetWagon(), ShipVehicleChangeInfo(), ShowNewGrfVehicleError(), SwapTrainFlags(), ToggleInvisibilityWithTransparency(), TownActionBuildStatue(), TownHouseChangeInfo(), TranslateRefitMask(), TriggerRoadStopRandomisation(), TriggerStationRandomisation(), TriggerWatchedCargoCallbacks(), TryBuildTownHouse(), UpdateOrderDest(), LinkGraphLegendWindow::UpdateOverlayCargoes(), LinkGraphLegendWindow::UpdateOverlayCompanies(), BaseGraphWindow::UpdateStatistics(), UpdateTownGrowth(), UpdateVehicleTimetable(), Vehicle::UpdateVisualEffect(), GroundVehicle< T, Type >::UpdateZPositionAndInclination(), and FreeUnitIDGenerator::UseID().
|
constexpr |
Toggles a bit in a variable.
This function toggles a bit in a variable. The variable is changed and the value is also returned. Parameter y defines the bit to toggle and starts at the LSB with 0.
x | The variable to toggle the bit |
y | The bit position to toggle |
Definition at line 181 of file bitmath_func.hpp.
Referenced by CmdBuildObject(), CmdRailTrackHelper(), CmdReverseTrainDirection(), CmdSignalTrackHelper(), BaseConsist::CopyConsistPropertiesFrom(), MenuClickSettings(), SelectCompanyLiveryWindow::OnClick(), GenerateLandscapeWindow::OnClick(), GraphLegendWindow::OnClick(), BaseGraphWindow::OnClick(), PaymentRatesGraphWindow::OnClick(), IndustryProductionGraphWindow::OnClick(), OskWindow::OnClick(), PickerWindow::OnClick(), CompanyStationsWindow::OnClick(), CompanyStationsWindow::OnDropdownSelect(), PerformStationTileSlopeCheck(), ReverseTrainDirection(), ToggleInvisibility(), ToggleRoadWaypointOnSnowOrDesert(), ToggleSnow(), ToggleTransparency(), ToggleTransparencyLock(), and Vehicle::UpdateVisualEffect().