Frosch/NotRoadTypes

From OpenTTD
Jump to: navigation, search

Contents

Road- and Tramtypes

Introduction

Road and tram are constructed independently. You can build road with a certain roadtype on a tile, and you can build tram with a certain tramtype on a tile. In general there are no implications between the two infrastructures, just like there are no implications to railtypes on levelcrossings, though rail-, road- and tramtypes can forbid levelcrossings.

Each tile may have one roadtype and one tramtype.

Roadtype and Tramtype labels

Roadtypes and tramtypes are identified via 4-character labels between NewGRFs. Labels of the different entities are independent. You can have roadtype "OTTD", tramtype "OTTD", railtype "OTTD", cargotype "OTTD", ... independently of each other, in the same game or in the same NewGRF.

By default OpenTTD knows these labels, and provides graphics for them:

Label Roadtype
ROAD Normal road
ELRD Electrified road
Label Tramtype
RAIL Tramway
ELRL Electrified tramway

Tramtypes use labels very close to railtype labels.

Note, that catenary is not specific to tramtypes. Trolley busses are not trams.

Nrt defaulttypes.png

Compatibility/Poweredness

This works the same as for railtypes. Vehicles have a specific road-/tramtype label.

The road-/tramtypes specify, which other tracktypes their vehicles can drive on.

Both road and tram may have catenary, but the catenaries exist independent of each other. A tile can show catenary, but still have "electrified road" and "not-electrified tram".


Example 1

4 roadtypes:

  • ROAD: Normal road
  • ELRD: Electrified road
  • OFFR: Off-road / dirt-road
  • HAUL: Heavy hauling road

Compatibility:

Roadtype/vehicletype Powered roadtypes
ROAD ROAD, ELRD
ELRD ELRD
OFFR OFFR, ROAD, ELRD, HAUL
HAUL HAUL

Note: Technically the specs do not enforce any "transitivity" for the compatibility. That means, if A can drive on B and B can drive on C, A does not necessarily drive on C.

Nrt example1 dot.png

(the image does not include the transitive relations)

Example 2

5 tramtypes:

  • RAIL: Normal rail
  • ELRL: Rail with catenary
  • 3RDR: Rail with 3rd rail
  • 3RDC: Rail with both catenary and 3rd rail
  • 3ORC: Vehicles which can switch between catenary or 3rd rail power supply.

The last type "3ORC" is technically no build-able tracktype, just a vehicle type. (This is currently not implemented) There are no vehicles which require both 3rd rail and catenary.

Tramtype/vehicletype Powered tramtypes
RAIL RAIL, ELRL, 3RDR, 3RDC, 3ORC
ELRL ELRL, 3RDC
3RDR 3RDR, 3RDC
3RDC 3RDC
3ORC ELRL, 3RDR, 3RDC

Nrt example2 dot.png

(the image does not include the transitive relations)

Sprite layers

When drawing road/tram tiles, multiple sprites are drawn in layers over each other.

General rules:

  • Pavement and roadsides (lamps, trees) are not part of any road- or tramtype. They are provided by the baseset only.
  • There is only one underlay, either from road or from tram. Road takes precedence.
  • Overlays are always drawn. (this is different to railtypes)
  • Both road and tram can draw catenary. Catenary sprites support company colour (1CC). If company is NONE, grey will be used for company colour.

Regular tiles

Layer Source Road only Road and Tram Tram only Composition
Foundation baseset X X X (1) Nrt layers.png
Grass or paved sidewalks baseset X X X (2)
Underlay from Roadtype Roadtype X X
Underlay from Tramtype Tramtype - X (3)
Overlay from Roadtype Roadtype X X
Overlay from Tramtype Tramtype X X (4)
Oneway signs baseset X X
Roadworks baseset X X X
Road catenary, back Roadtype X X
Tram catenary, back Tramtype X X (5)
Roadside (lamps, trees), back baseset X X X (6)
Vehicles X X X
Roadside (lamps, trees), front baseset X X X (7)
Road catenary, front Roadtype X X
Tram catenary, front Tramtype X X (8)

Level crossing

Layer Source Road only Road and Tram Tram only
Foundation baseset X X X
Grass or paved sidewalks baseset X X X
Underlay from Roadtype Roadtype X X
Underlay from Tramtype Tramtype - X
Overlay from Roadtype Roadtype X X
Overlay from Tramtype Tramtype X X
Overlay from Roadtype Roadtype X X
Overlay from Tramtype Tramtype X X
Rail overlay RailType X X X
Road catenary, back Roadtype X X
Tram catenary, back Tramtype X X
Rail catenary, back RailType X X X
Crossing bars, back RailType X X X
Vehicles X X X
Crossing bars, front RailType X X X
Rail catenary, front RailType X X X
Road catenary, front Roadtype X X
Tram catenary, front Tramtype X X

Road depot

Layer Source Road only Road and Tram Tram only
Foundation baseset X X
Depot, back Road/Tramtype X X
Road/Tram overlay (if default depot gfx) Road/Tramtype X X
Depot, front Road/Tramtype X X

Drive-in road stop

Layer Source Road only Road and Tram Tram only
Foundation baseset X
Station, back baseset X
Road overlay Roadtype X
Road catenary, back Roadtype X
Vehicles X
Station, front baseset X
Road catenary, front Roadtype X

Drive-through road-stop

... similar to regular tiles ...

Bridge, Head

... similar to regular tiles ...

Bridge, Middle

... similar to regular tiles ...

Tunnel

... similar to regular tiles ...

NewGRF format

Global stuff

Road-/Tramtype translation table

NFO
Action 0 Feature 8 Properties 0x16 (roadtypes) and 0x17 (tramtypes) work the same as 0x12 for railtypes
NML
"roadtypetable" and "tramtypetable" work the same as "railtypetable"

Testing for road-/tramtypes

NFO
Action 7 tests 0x0F (roadtype not defined), 0x10 (roadtype defined), 0x11 (tramtype not defined), 0x12 (tramtype defined) work the same as 0x0D and 0x0E for railtypes.
NML
"roadtype_available" and "tramtype_available" work the same as "railtype_available"

Action 5 tram graphics

Type 0B is extended to now provide 119 sprites (6 more than before).

Originally sprites 49..54 provided graphics for the electrified tram depot, which include the tram tracks.

The new sprites 113..118 provide graphics for electrified depots, which do not include tracks. These sprites are used for all electrified road and tram depots, where the road-/tramtype does not supply custom depot sprites. The regular road-/tramtype overlay sprite is drawn over the ground sprite of the depot to provide track graphics.

The old sprites 49..54 are only used for compatibility, if no new sprites 113..118 are provided.

Vehicle stuff

Properties

Road-/tramtype of vehicle:

NFO
Property 0x05 (byte) specifies the entry from the road-/tramtype translation table.
NML
"road_type", "tram_type" specifies the entry from the road-/tramtype translation table. ROADVEH_FLAG_TRAM must be set/cleared nevertheless.

If the property is not set, then road vehicles default to "ROAD" and trams default to "ELRL".

Variables

Current road-/tramtype under vehicle:

NFO
Var 0x4A works the same as for trains. Bit 8 "is/would be powered" is always set.
NML
"current_roadtype" and "current_tramtype" work the same as "current_railtype".

Road-/Tramtype

Feature:

NFO
0x12 for roadtypes, 0x13 for tramtypes
NML
FEAT_ROADTYPES, FEAT_TRAMTYPES

There is no "parent" scope.

There is a global limit of 15 roadtypes and 15 tramtypes, including the default types.

Properties

NFO NML Notes
0x08 (dword) label
0x09 (word) toolbar_caption
0x0A (word) menu_text
0x0B (word) build_window_caption
0x0C (word) autoreplace_text
0x0D (word) new_engine_text
0x0F (*) powered_roadtype_list, powered_tramtype_list there is no difference between "powered" and "compatible" for road-/tramtypes
0x10 (byte) roadtype_flags, tramtype_flags 0x01 = ROADTYPE_FLAG_CATENARY = TRAMTYPE_FLAG_CATENARY
0x02 = ROADTYPE_FLAG_NO_LEVEL_CROSSING = TRAMTYPE_FLAG_NO_LEVEL_CROSSING
0x13 (word) construction_cost Defaults: ROAD = 8, ELRD = 16, RAIL = 8, ELRL = 16
0x14 (word) speed_limit Unit is the same as for road vehicles. 0x100 = 128 km-ish/h = 80 mph
0x16 (byte) map_colour Defaults: 0x01 for all
0x17 (dword) introduction_date
0x18 (*) requires_roadtype_list, requires_tramtype_list
0x19 (*) introduces_roadtype_list, introduces_tramtype_list
0x1A (byte) sort_order Defaults: ROAD = 0x07, ELRD = 0x17, RAIL = 0x07, ELRL = 0x17
0x1B (word) name
0x1C (word) maintenance_cost Defaults: ROAD = 16, ELRD = 24, RAIL = 16, ELRL = 24
0x1D (*) alternative_roadtype_list, alternative_tramtype_list

Variables

NFO NML Notes
0x40 (byte) terrain_type
0x42 (byte) level_crossing_status Level crossing sprites are provided by RailType only though.
0x43 (dword) build_date Only available for road/tram depots.
0x44 (byte) town_zone Currently not available for bridges and stations.
0x5F (*) random_bits 2 pseudo random bits

Graphics

NFO Action3 Id NML Required Notes Action 5 equivalent
0x00 gui optional 12 sprites (6 gui icons, 6 cursors)

Nrt gui.png

0-1, 4 new, 2-3, 4 new
0x01 track_overlay optional for road, required for tram 19 sprites (11 roadbit combinations, 4 slopes, 4 dead ends)

Nrt overlay.png

4-22
0x02 underlay required 19 sprites (11 roadbit combinations, 4 slopes, 4 dead ends)

Nrt underlay.png

27-45
0x04 catenary_front optional 29 sprites (11 roadbit combinations, 4 slopes, 4 dead ends, 4 tunnels, 2 bridge middle, 4 bridge ramps)

Nrt catenary front.png

56-62, 64-67, 72-75, 4 new, 80-83, 97-98, 103-106
0x05 catenary_back optional 29 sprites (11 roadbit combinations, 4 slopes, 4 dead ends, 4 tunnels (unused), 2 bridge middle, 4 bridge ramps)

Nrt catenary back.png

84-94, 68-71, 4 new, 4 new, 95-96, 99-102
0x06 bridge_surfaces required 6 sprites (2 bridge middle, 4 bridge ramps)

Nrt bridge.png

107-112
0x08 depots optional 6 sprites

Nrt depot.png
If not present, the default depot sprites (depending on catenary flag) plus track overlay are drawn.
If present, the depot sprites are expected to include track overlay graphics.

49-54 or 113-118
0x0A drive-in stops require for road, invalid for tram 4 sprites (overlays for drive-in road stops)

Nrt drivein.png

new

ToDo list

Which roadtypes are build and used by towns?

Current status:

  • Towns only build ROAD. Houses grow along all road- and tramtypes.
  • Flag to enable houses along some road- or tramtypes. Disabled for default tramtypes.

Future:

  • Flag to enable construction by towns. Which type do towns choose? The newest? What is the newest? How/when do they upgrade?

Disallow construction for drive-in stops

Current status:

  • Roadtypes have drive-in stops, tramtypes do not.

Future:

  • Flag to disable drive-in stops for roadtypes. Tramtypes remain always disabled.

Roadsides / fences

Current status:

  • The default roadsides are always drawn

Future:

  • Flag to enable default pavement.
  • Flag to enable default roadsides (lamps, trees).
  • Optional sprites for rail-style "fences" (highway barriers, trees, ...)

Draw underlay for both road and tram

Current status:

  • When there is both road and tram on a tile, and tram has some trackbits which road doesn't, then it currently looks like this.

Future:

  • Instead tram-underlay should also be drawn. The total order would be
    • Grass ground
    • Tram underlay
    • Road underlay (drawn after tram, so it "takes precedence".)
    • Road overlay
    • Tram overlay

Problem:

  • The default roads do not provide road overlays. So this would need new Action5 sprites, and is not completely compatible with existing landscape and infrastructure NewGRFs and basesets.

Related:

  • The same applies to rail level crossings when using default railtypes. However, with NewRailTypes this is already better.
  • This can also be extended for smooth road-type transitions on junctions:
    • If a roadtile connects to two tarmac road tiles and one dirt road tile, then it should draw the dirt underlay to the dirt tile and the tarmac underlay over it.
    • Something similar is already done for catenary continuation.

Independent movement for road vehicle and trams

Current status:

  • Road vehicles and trams occupy the same space and block eachother's movement.

Future:

  • Flag to enable trams to move independent of present road vehicles. (for example: suspension railway)
    • Vehicles clip through each other.
    • Track sprites would need drawing like catenary.
    • Next step "regular tram under suspension rail" fails.

Non-constructible rail-/road-/tramtypes to model vehicle compatibility/poweredness

Current status:

  • Vehicles can only use defined tracktypes. Tracktypes are buildable, if a vehicle exists for them.

Future:

  • Distinguish "track and vehicle type" and "vehicle-only type".
  • "Vehicle-only types" are used by vehicles and reference other types for compatibility, but are not buildable themself.
  • "Vehicle-only types" should not count towards the "maximum 15 types" limit.
  • "Vehicle-only types" are visible in dropdowns that filter vehicles, like in the autoreplace GUI.
  • See also Example 2 above, and FS#5006.

Foundations

Current status:

  • Road, tram and rail use the regular foundation sprites.

Future:

  • Optional sprites for railtypes, roadtypes and tramtypes. (precedence in this order)

Variable to test presence of road/tram

To draw different graphics depending on whether there is another road/tramtype present on the tile, add a new variable:

  • Var 0x45, bit 0..7 "current_roadtype"
    • 00 - FD: Entry from road translation table.
    • FE: Road present, but not in translation table.
    • FF: No road present
  • Var 0x45, bit 8..15 "current_tramtype"
    • 00 - FD: Entry from tram translation table.
    • FE: Tram present, but not in translation table.
    • FF: No tram present

TODO Other useful info, maybe rather 16bits per road/tram?

Vehicle variable to test "poweredness" for certain road/tram/railtype

This is to allow powered vehicles to check for track types with even-better power supply.

  • Vehicle var 0x63. Parameter is road/tram/railtype to check for. Result is
    • 0 not compatible
    • 1 compatible (only for trains)
    • 2 compatible and powered
    • 0xFF unknown tracktype

More information for the overlay graphics

Pass information about the tile context in var10, in particular for the overlay sprites:

  • Regular tile
  • Level crossing
  • Drive-through stop
  • Road depot
  • Bridge head
  • Bridge middle
  • Tunnel entry
  • ...
Personal tools