GRF Version 8

Some proposals for modifications of newgrf specs (grf version 8) to improve usability and extensibility

Contents

Vehicle variable 42 field "cc"

Currently: Untranslated cargo.
Proposal: Translated cargo. The translation table of the grf the varaction2 belongs to will be used. 0xFF if the cargo is not part of it. (like var 47)
Grf-Version: Does this need bumping? IMO no, as the current behaviour is not useable at all. The change would fit into version 7. OTOH (according to Dalestan) it is a change, so bump needed.
Implementation: 70_translated_var42.diff

Vehicle property 15/10/0C "default cargo"

Default cargo

Currently: Untranslated cargo.
Proposal: Translated cargo. If the specified cargo is not present, the first refittable will be used. It's the job of the GRF to check available cargos via action 7, and set other default cargos, if they are not fine with the "first refittable"-rule.
Note: If the vehicle is refittable, the default cargo must be one of the refittable cargos; else the the "first refittable"-rule applies.
Implementation: 82_translate_default_cargo.diff

First refittable

Currently: First refittable cargoslot is picked. (That means "lowest number" of untranslated cargo)
Proposal: Use first refittable cargo wrt. the GRFs cargo translation table. (nitpick: the CTT of the GRF providing the refit mask)
Grf-Version: Changed behaviour of existing GRFs, so bump needed.
Implementation: 86_first_refittable_from_ctt.diff

Introduce 32bit parameters for 60+x variables

This is possible via variable 7B, which one can use to put 32 bits into the accumulator and pass them to any 60+x variable. Esp. useful for vehicle variable 60
Grf-Version: No bump needed.
Implementation: 40_32bit_parameter_esp_var60.diff

No longer fallback stuff for basecost multipliers

Implementation: 50_no_pricebase_fallback.diff

Action 13

Add a language code to action 13.
Implementation: r23391

Remove 0xFF?? callback results

Remove the 0xFF?? downwards-compatibility stuff to support full 15 bit callbacks. (Dalestan's suggestion)
Grf-Version: Bump needed.
Implementation: 20_callback_result.diff

Revise all callback and their allowed result values

Goals:

Complete different callback results

Callback 16: Articulated vehicles

Currently: Bit 0-6 ID, bit 7 reverse flag, 0xFF stop

  1. Proposal: Bit 0-13 ID, bit 14 reverse flag, 0x7FFF stop; 0x3F?? and 0x7F?? reserved (Note: 0x7FFF needs 2b))
  2. Proposal: Bit 0-6 ID, bit 7 reverse flag, 0xFF stop; 0x7E/0xFE use ID from register 0x100

Grf-Version: Proposal 1 needs bump to version 8, proposal 2 not necessarily. (apart from general 8->15 bit bump)
Implementation for proposal 1: 30_articulated_cb.diff

Callback 22: Industry availability

Currently: Zero to allow construction, non-zero to disallow.

  1. Proposal: Return probability (like property 18); 0x00 to disallow; 0x01 - 0xFF for probability, 0x100 to allow with probability from property 22.

Grf-Version: Bump needed.
Implementation: 90_industryprob.diff

Deprecation of callbacks

The callbacks

are no longer called in grf version 8.

Note: Callback 10 is kept as it is likely to gain more functionality at some point.

Grf-Version: Bump needed.
Implementation: 120_roadvehlen_property.diff 123_deprecate_11.diff 125_deprecate_12.diff

Boolean results

These callback return boolean results:

Currently: Most callbacks return zero or non-zero. Some return 0 or 1.
Proposal: All callback shall return 0 or 1. Other values are considered reserved and trigger error messages when used.
Grf-Version: Bump needed.
Implementation: 100_bool_cbs.diff

Callbacks returning D0xx texts

These callbacks can return D0xx texts:

Currently: Most of the callbacks return 0x00 to 0x3FF for D0xx texts, 0x400 for "default behavior" and other values above 0x400 for special stuff.
Proposal: Make all callbacks behave like that.
Grf-Version: Bump needed.
Implementation: 60_consistent_slope_check_cb.diff 65_D0xx_cbs.diff

Other callbacks with limited range

The following callbacks do not use all 15 bits for their results:

Proposal: The unused bits will be checked for being zero; else an error message is displayed to the user.
Grf-Version: No bump needed.
Implementation: 110_check_callback_results.diff

Revise height variables

There are two units for height in TTD. "Pixels" and "heightlevels". One heightlevel has 8 pixels. Various variables report heights in one of those units to NewGRFs. In most cases using 8 bits. Many of these variables will break when more-height-levels (more than 16 height levels; up to 256) are added. There is no way around breaking existing NewGRFs in this case.

The goal of GRF version 8 is here to allow NewGRFs handle more heightlevels. Various variables are changed to return heighlevels instead of pixels. (Simliar as GRF version 7 changes many variables to return translated cargobits instead of cargo slots.)

Stuff which remains unchanged and will continue to work

Implementation: 154_var44.diff

Stuff which remains unchanged, will somewhat break with more heightlevels, and will remain unfixed/unchanged

Stuff that changes behaviour in GRF version 8

Action 0 snow line height table

Currently: Pixels, 0x10 - 0x88
Proposal: 0x00 - 0xFE (automatically scaled to maximum height level), 0xFF for 'no snow'.
Behaviour with more-height-levels and GRF version < 8: Values are scaled automatically. Keeps working.
Grf-Version: Bump needed.
Implementation: 130_snowlinetable.diff

Snow line variables

Currently: Pixels, 0xFF for 'no snow'
Proposal: Height levels, 0xFF for 'no snow'
Behaviour with more-height-levels and GRF version < 8: Values bigger than 0xFE get clamped. GRFs are likely to continue working for up to 32 height levels, but will likely break when more are used.
Grf-Version: Bump needed.
Implementation: 140_snowvariables.diff

Other height variables

Currently: Pixels
Proposal: Height levels
Behaviour with more-height-levels and GRF version < 8: Values bigger than 0xFF are clamped to 0xFF. GRFs are likely to continue working for up to 32 height levels, but will likely break when more are used.
Grf-Version: Bump needed.
Implementation: 150_nearbyheight.diff 152_cb28.diff

Callback 144

Currently: Heightlevel of north corner, 4 bit. (will break for more-height-levels)
Proposal: Complete new format for var10: xTHHRRtt

This format is also more consistent with the nearby land info variables.
Implementation: 156_cb144.diff

New Action D patch/settings variables 14 "Maximum height level"

Proposal: Maximal allowed height level; currently fixed at 15
Grf-Version: No bump needed.
Implementation: 160_patchvar14.diff

Old proposals, which are already achieved by different means

Callback 17: House construction check

Currently: Called for one tile, which would be part of the house.
Proposal: Always call for the north tile.
Grf-Version: No bump needed.
Implementation: Already implemented in trunk long ago. 0.7-ish or so.

Specify used palette

  1. Proposal: Append a byte at the end of Action8. 0 = don't care, 1 = dos, 2 = win. (0 is a nice default value) Optional for grf version < 8, mandatory for >= 8.
  2. Proposal: 0 = dos, 1 = win, 2 = don't care (like var 0D/8D). Optional for grf version < 8, mandatory for >= 8.

Implementation: Goal was archived with Action 14.

Handle any non-specified palette as windows palette in order to 'honour' the fact that virtually all old NewGRFs use that - and it's tedious to configure that when always this setting will be needed.
Implementation: Advanced setting in trunk.

Maybe some grf version for compatible grfs?

16 bit for incompatible version
16 bit for compatible version
Implementation: Goal was archived with Action 14.