MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetServiceIntervalClamped

Function GetServiceIntervalClamped

src/order_cmd.cpp:1865–1875  ·  view source on GitHub ↗

* Clamp the service interval to the correct min/max. The actual min/max values * depend on whether it's in days, minutes, or percent. * @param interval The proposed service interval. * @param ispercent Whether the interval is a percent. * @return The service interval clamped to use the chosen units. */

Source from the content-addressed store, hash-verified

1863 * @return The service interval clamped to use the chosen units.
1864 */
1865uint16_t GetServiceIntervalClamped(int interval, bool ispercent)
1866{
1867 /* Service intervals are in percents. */
1868 if (ispercent) return Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT);
1869
1870 /* Service intervals are in minutes. */
1871 if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) return Clamp(interval, MIN_SERVINT_MINUTES, MAX_SERVINT_MINUTES);
1872
1873 /* Service intervals are in days. */
1874 return Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
1875}
1876
1877/**
1878 *

Callers 4

CmdChangeServiceIntFunction · 0.85
CanUpdateServiceIntervalFunction · 0.85
OnClickMethod · 0.85
OnDropdownSelectMethod · 0.85

Calls 1

ClampFunction · 0.85

Tested by

no test coverage detected