NewGRF New Landscape Addition to NewGRF Specifications in JGR's Patchpack in NML

This document describes the non-standard addition of the NewGRF new landscape feature to the Official OpenTTD NML Specifications, as implemented in this patchpack, and the associated NML fork

This feature allows NewGRF custom graphics using switches and spritesets for landscape tiles. Currently this includes: rock tiles.

This feature may not necessarily match implementations of additional landscape graphics features in other patches, branches, etc.
This feature as implemented here MAY also be present in other patchpacks.

The feature identifier is FEAT_NEWLANDSCAPE.
There is no permanent storage associated with this feature.

See the NewGRF additions (NML) document for background information on additions to NML.

See the associated non-NML document for more details on the NewGRF new landscape feature.

This feature will be automatically skipped when loaded into a version of OpenTTD which does not support this feature.
If this feature is the only significant thing in this GRF, then extended_feature_test("new_landscape") SHOULD be called and some message, error or other form of signalling to the user used to inform the user that this version of OpenTTD does not support the feature, if the return value is false.
Otherwise the GRF could silently do nothing instead of the expected functionality, creating confusion for end users.

Sections:

New Landscape IDs

The ID field for an item must be set to one of the IDs in the table below (further IDs may be allocated for other purposes in future).

IDLandscape type
NEW_LANDSCAPE_ID_ROCKSRocky tiles

New Landscape Properties

PropertyValue rangeComment
enable_recolour0 or 1 Enable recolouring of graphics.
When enabled, in addition to returning a sprite, register 0x100 may be set to the following using STORE_TEMP:
BitsMeaning
0 - 23Recolour sprite to use. Set to 0 for no recolouring.
24 - 31Reserved, set to zero.
enable_draw_snowy_rocks0 or 1 Enable drawing of rock tiles covered by snow, for this GRF.
(This only takes effect from new_landscape version 2).

New Landscape Variables

NameValue rangeComment
terrain_typeTILETYPE_XXXXXX = NORMAL | DESERT | RAIN_FOREST | SNOW
tile_slopeSLOPE_XXXSee tile slopes for an overview of possible values
tile_height0..255Height of the lowest corner of the tile
tile_hash0..4294967295Hash value derived from the coordinates of the tile, suitable for pseudo-randomising graphics
landscape_typeNEW_LANDSCAPE_TYPE_XXXLandscape type
XXX = ROCKS
snow_present0 or 1Snow is present on this tile, at any density.
This requires new_landscape, version 2.
ground_density0..3Ground density (if snow_present is 1, this is the snow density).
This requires new_landscape, version 2.

Variables that require one or more parameters:
NameArgumentsValue rangeComment
nearby_tile_slopex, y offset (-8..7)SLOPE_XXXSlope of a nearby tile
nearby_tile_is_same_typex, y offset (-8..7)0 | 1Is nearby tile the same landscape type as this one?
nearby_tile_is_waterx, y offset (-8..7)0 | 1Is nearby tile a water tile?
nearby_tile_terrain_typex, y offset (-8..7)See terrain_type
nearby_tile_water_classx, y offset (-8..7)WATER_CLASS_XXXXXX = [NONE | SEA | CANAL | RIVER]
Note that tiles for which nearby_tile_is_water is 0 may still have a water class, e.g. industry tiles with water beneath them.
nearby_tile_heightx, y offset (-8..7)The minimum height of the given tile in height level units
nearby_tile_classx, y offset (-8..7)tile class
nearby_tile_infox, y offset (-8..7)Above nearby tile variables in one variable (all of variable 0x60)

Syntax example

grf {
	...
}

if (!extended_feature_test("new_landscape")) {
	error(FATAL, string(STR_UNSUPPORTED_VERSION));
}


spriteset spriteset_rocks {
	/* 19 tile sprites in the standard order */
}

switch (FEAT_NEWLANDSCAPE, SELF, switch_rocks, ...) {
	...
}

item (FEAT_NEWLANDSCAPE, item_rocks, NEW_LANDSCAPE_ID_ROCKS)  {
	property {
		enable_recolour: 0;
	}
	graphics {
		default: switch_rocks;
	}
}