Additions to AI/GS Script Specifications in JGR's Patchpack

This document describes non-standard additions to the Official OpenTTD AI and GS Specifications which are present in this patchpack.

These additions MAY also be present in other patchpacks. They MAY be removed or moved in future, if necessary.

Scripts which use any of these features SHOULD check whether the feature is present and if not, fallback to not using it and/or emitting a clear and end-user friendly error message.
Testing for the presence of methods may be done using the "in" operator.

Contents:

Date: GSDate Class and AIDate Class

Additional Static Public Member Functions:

static int32 GetDayLengthFactor ()
Get current day length factor.
static bool IsTimeShownInMinutes ()
Get whether time is shown in minutes in the game settings.
This ignores the "Use client time settings instead of savegame time settings" setting.
static int32 GetTicksPerMinute ()
Get the ticks per minutes in the game settings.
This ignores the "Use client time settings instead of savegame time settings" setting.
static DateTicksScaled GetCurrentScaledDateTicks ()
Get the current scaled date ticks.
This increments at the same rate regardless of the day length factor.
Changing the day length factor will also change this value.
static int32 GetHour (DateTicksScaled ticks)
Get the hour of the given scaled date ticks value.
This ignores the "Use client time settings instead of savegame time settings" setting.
static int32 GetMinute (DateTicksScaled ticks)
Get the minute of the given scaled date ticks value.
This ignores the "Use client time settings instead of savegame time settings" setting.

Marine: GSMarine Class and AIMarine Class

Additional Static Public Member Functions:

static bool BuildRiver (TileIndex tile)
Builds a river on tile (subject to permissions/settings).
All other details are the same as BuildCanal.

Road: GSRoad Class and AIRoad Class

Additional Static Public Member Functions:

static bool HasRoadTramType(TileIndex tile, RoadTramTypes road_tram_type)
Check if a tile has the given road tram type.
static RoadType GetRoadType(TileIndex tile, RoadTramTypes road_tram_type)
Get the RoadType that is used on a tile.
static bool IsCatenaryRoadType(RoadType roadtype)
Checks whether the given road type uses a catenary.
static bool IsNonLevelCrossingRoadType(RoadType roadtype)
Checks whether the given road type disallows level crossings.
static bool IsNoTownHousesRoadType(RoadType roadtype)
Checks whether the given road type cannot be used by towns to build houses.
static bool IsTownBuildableRoadType(RoadType roadtype)
Checks whether the given road type is buildable by towns.
static RoadPieces GetRoadPieces(TileIndex tile, RoadTramTypes road_tram_type)
Get the RoadPieces that are on a tile.
static OneWayInfo GetOneWayInfo(TileIndex tile)
Get info about the one-way state of a tile.

Company: GSCompany Class and AICompany Class

Additional Static Public Member Functions:

static bool GetAnnualExpenseValue (CompanyID company, uint32 year_offset, ExpensesType expenses_type)
Get the annual expense value for the given company.
year_offset is relative to the current year and must be either: 0, 1, or 2.

Additional Enum Values:

ExpensesType
Additional value: EXPENSES_SHARING_COST
Infrastructure sharing costs.
Additional value: EXPENSES_SHARING_INC
Infrastructure sharing income.
ExpensesType is additionally available via AICompany.

Inflation: GSInflation Class and AIInflation Class

Static Public Member Functions:

static int64 GetPriceFactor ()
Get the inflation factor for prices.
Returns the inflation factor as a fixed point value (16 bits).
static int64 GetPaymentFactor ()
Get the inflation factor for payments.
Returns the inflation factor as a fixed point value (16 bits).
static bool SetPriceFactor (int64 factor)
Set the inflation factor for prices (GS only).
The inflation factor is a fixed point value (16 bits).
static bool SetPaymentFactor (int64 factor)
Set the inflation factor for payments (GS only).
The inflation factor is a fixed point value (16 bits).

Command Asynchronous Mode: GSAsyncMode Class

Public Constructor:

GSAsyncMode (bool asynchronous)
Creating an instance of this class switches the asynchronous execution mode for commands.
A value of true sets the mode to Asynchronous, the commands you execute are queued for later execution, and the script is not delayed waiting for the command result. The estimated result is returned to the script. The actual cost and whether the command succeeded when the command is eventually executed may differ from what was returned to the script.
A value of false sets the mode to Non-Asynchronous, this is the normal mode of executing commands.
The original mode is stored and recovered from when ever the instance is destroyed.
Use in a similar way to the GSTestMode class.