Skip to content
Permalink
Browse files

Support for Not Road Types (#30)

* Codechange: (WIP) add roadtype on 0x12 by cargo-culting railtype code and changing prop/var names

* Codechange: more complete implementation of roadtypes

* Fix: 'roadtypes' needed added to parser production rules; tests now pass

* Change: add name property to example roadtypes grf

* Change: add roadtype flags to global constants

* Change: set correct strings in example roadtype grf

* Change: extended roadtype example

* Feature: split tramtype out to defined feature (on 0x13)

* Change: basic sprites now correct in road example

* Change: example blue and red roads

* Change: add example yellow road

* Codechange: improved structure of example roadtypes grf

* Change: adjust example tramtype names, and set catenary flag for one of them

* Change: just use the normal gui for the example tramtypes

* Change: remove 'default' road and tram from example roadtypes grf

* Change: Make road- and tramtype IDs not start with zero to simplify OTTD debugging.

* Add: Missing TramType stuff.

* Change: Adjust Road/TramTypes to revised spec.

* Codechange: graphics for green 'tram'

* Codechange: green tram now green (road) in example grf

* Fix: Tramtype example.

* Codechange: add drive-in roadstop overlays for red, yellow and blue roads

* Add: drive-in roadstops to test grf.

* Fix: Depot alignment in test GRF.

* Remove: Properties for compatible road types, station graphics, acceleration model.

* Add: Roadvehicle property 'road_type'.

* Fix: Road and tram translation table.

* Add: Functions roadtype_available and tramtype_available.

* Add: Vehicle variables current_roadtype and current_tramtype.

* Add: tram_type property for road/tram symmetry.

* Fix: roadtypetable and tramtypetable missing from constants list

* Change: add example trucks for BLUE and YELL roadtypes

* Fix: YELL road example truck was using RED_TEST roadtype group; fix that and add a RED_TEST truck

* Change: set example red electric road 'powered...' property to ROAD and BLUE

* Change: Add a red vehicle as testcase.

* Change: example ELTM is not powered on TRAM

* Change: example grfs - '__TM' is harder to type than '__TR' as a tramtype label

* Change: Adjust roadtype examples to new default labels.

* Change: Remove roadtype curve_speed_multiplier property.

* Fix: Default road/tram translation table.

* Fix: Road/tramtype speed limit unit conversion.

* Fix: If not roadtype- or tramtypetable is provided, OpenTTD defaults to the old ROAD and ELRL.

* Feature: flags for roadtype and tramtype house construction

* Change: Update road type flags.
  • Loading branch information...
PeterN authored and planetmaker committed Oct 7, 2019
1 parent f62c56f commit 62cab41d4a1f84c4b96cf3e5b1fe2439532ba891
Showing with 1,007 additions and 18 deletions.
  1. +159 −0 examples/road_vehicle/example_road_vehicle.nml
  2. +4 −1 examples/road_vehicle/lang/english.lng
  3. +347 −0 examples/roadtype_and_tramtype/example_roadtype_and_tramtype.nml
  4. BIN examples/roadtype_and_tramtype/gfx/depot_electric.png
  5. BIN examples/roadtype_and_tramtype/gfx/depot_normal.png
  6. BIN examples/roadtype_and_tramtype/gfx/fences.png
  7. BIN examples/roadtype_and_tramtype/gfx/gui_erail.png
  8. BIN examples/roadtype_and_tramtype/gfx/gui_rail.png
  9. BIN examples/roadtype_and_tramtype/gfx/lc_left.png
  10. BIN examples/roadtype_and_tramtype/gfx/lc_right.png
  11. BIN examples/roadtype_and_tramtype/gfx/rails_overlays.png
  12. BIN examples/roadtype_and_tramtype/gfx/roads_blue.png
  13. BIN examples/roadtype_and_tramtype/gfx/roads_red.png
  14. BIN examples/roadtype_and_tramtype/gfx/roads_underlay.png
  15. BIN examples/roadtype_and_tramtype/gfx/roads_yellow.png
  16. BIN examples/roadtype_and_tramtype/gfx/tram_green.png
  17. BIN examples/roadtype_and_tramtype/gfx/tunnel_track.png
  18. +31 −0 examples/roadtype_and_tramtype/lang/english.lng
  19. +64 −0 nml/actions/action0.py
  20. +97 −1 nml/actions/action0properties.py
  21. +2 −2 nml/actions/action2.py
  22. +40 −7 nml/actions/action2var_variables.py
  23. +26 −1 nml/actions/action3_callbacks.py
  24. +2 −0 nml/ast/general.py
  25. +63 −0 nml/ast/roadtypetable.py
  26. +63 −0 nml/ast/tramtypetable.py
  27. +11 −3 nml/editors/extract_tables.py
  28. +1 −1 nml/expression/__init__.py
  29. +25 −1 nml/expression/functioncall.py
  30. +31 −0 nml/global_constants.py
  31. +39 −1 nml/parser.py
  32. +2 −0 nml/tokens.py
@@ -69,6 +69,11 @@ cargotable {
WOOD, // Wood (piece goods)
}

roadtypetable {
ROAD, ELRD, YELL,
RED_TEST: [RED_, REDR, ROAD]
}

/* Sprite template for a truck */
template tmpl_truck(x) {
[ 0 + x, 0, 8, 18, -3, -10]
@@ -145,6 +150,160 @@ item(FEAT_ROADVEHS, flatbed_truck_1) {
/* Properties common to all vehicle types */
name: string(STR_NAME_FLATBED_TRUCK_1);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
road_type: ROAD;
introduction_date: date(1926,01,01);
model_life: 65;
/* retire_early not set, use default retirement behaviour */
vehicle_life: 15;
reliability_decay: 20;
refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS);
non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED);
/* Livestock, wool and fibre crops can be transported acc. cargo classes
* But we don't want that, so disable refitting for them.
* Scrap metal, petrol and refined products cannot be transported acc. cargo classes
* We do want to transport those, so enable refitting for them. */
cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR];
cargo_disallow_refit: []; // we allow other cargoes, if class matches
loading_speed: 5;
cost_factor: 108;
running_cost_factor: 90;
/* cargo_age_period is left at default */

/* RV-specific properties */
sprite_id: SPRITE_ID_NEW_ROADVEH;
speed: 48 km/h;
misc_flags: bitmask(ROADVEH_FLAG_2CC);
refit_cost: 0; // Refitting is free
/* callback_flags are not set, no need to manually enable callbacks */
running_cost_base: RUNNING_COST_ROADVEH;
power: 120 hp;
weight: 9.5 ton;
/* TE and air drag coefficient is left at default */
cargo_capacity: 20; // Changed by callback
sound_effect: SOUND_BUS_START_PULL_AWAY;
/* Visual effect is left at default (no effect) */
}

/* Define graphics for various cargo types, as well as the capacity callback */
graphics {
cargo_capacity: flatbed_truck_1_capacity_switch;
PAPR: flatbed_truck_1_paper;
STEL: flatbed_truck_1_steel;
COPR: flatbed_truck_1_copper;
WOOD: flatbed_truck_1_wood;
default: flatbed_truck_1_goods; // Default to Goods.
}
}

/* Define the road vehicle */
item(FEAT_ROADVEHS, flatbed_truck_2) {
property {
/* Properties common to all vehicle types */
name: string(STR_NAME_FLATBED_TRUCK_2);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
road_type: ELRD;
introduction_date: date(1926,01,01);
model_life: 65;
/* retire_early not set, use default retirement behaviour */
vehicle_life: 15;
reliability_decay: 20;
refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS);
non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED);
/* Livestock, wool and fibre crops can be transported acc. cargo classes
* But we don't want that, so disable refitting for them.
* Scrap metal, petrol and refined products cannot be transported acc. cargo classes
* We do want to transport those, so enable refitting for them. */
cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR];
cargo_disallow_refit: []; // we allow other cargoes, if class matches
loading_speed: 5;
cost_factor: 108;
running_cost_factor: 90;
/* cargo_age_period is left at default */

/* RV-specific properties */
sprite_id: SPRITE_ID_NEW_ROADVEH;
speed: 48 km/h;
misc_flags: bitmask(ROADVEH_FLAG_2CC);
refit_cost: 0; // Refitting is free
/* callback_flags are not set, no need to manually enable callbacks */
running_cost_base: RUNNING_COST_ROADVEH;
power: 120 hp;
weight: 9.5 ton;
/* TE and air drag coefficient is left at default */
cargo_capacity: 20; // Changed by callback
sound_effect: SOUND_BUS_START_PULL_AWAY;
/* Visual effect is left at default (no effect) */
}

/* Define graphics for various cargo types, as well as the capacity callback */
graphics {
cargo_capacity: flatbed_truck_1_capacity_switch;
PAPR: flatbed_truck_1_paper;
STEL: flatbed_truck_1_steel;
COPR: flatbed_truck_1_copper;
WOOD: flatbed_truck_1_wood;
default: flatbed_truck_1_goods; // Default to Goods.
}
}

/* Define the road vehicle */
item(FEAT_ROADVEHS, flatbed_truck_3) {
property {
/* Properties common to all vehicle types */
name: string(STR_NAME_FLATBED_TRUCK_3);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
road_type: YELL;
introduction_date: date(1926,01,01);
model_life: 65;
/* retire_early not set, use default retirement behaviour */
vehicle_life: 15;
reliability_decay: 20;
refittable_cargo_classes: bitmask(CC_PIECE_GOODS, CC_EXPRESS);
non_refittable_cargo_classes: bitmask(CC_PASSENGERS, CC_REFRIGERATED);
/* Livestock, wool and fibre crops can be transported acc. cargo classes
* But we don't want that, so disable refitting for them.
* Scrap metal, petrol and refined products cannot be transported acc. cargo classes
* We do want to transport those, so enable refitting for them. */
cargo_allow_refit: [LVST, WOOL, SCRP, FICR, PETR, RFPR];
cargo_disallow_refit: []; // we allow other cargoes, if class matches
loading_speed: 5;
cost_factor: 108;
running_cost_factor: 90;
/* cargo_age_period is left at default */

/* RV-specific properties */
sprite_id: SPRITE_ID_NEW_ROADVEH;
speed: 48 km/h;
misc_flags: bitmask(ROADVEH_FLAG_2CC);
refit_cost: 0; // Refitting is free
/* callback_flags are not set, no need to manually enable callbacks */
running_cost_base: RUNNING_COST_ROADVEH;
power: 120 hp;
weight: 9.5 ton;
/* TE and air drag coefficient is left at default */
cargo_capacity: 20; // Changed by callback
sound_effect: SOUND_BUS_START_PULL_AWAY;
/* Visual effect is left at default (no effect) */
}

/* Define graphics for various cargo types, as well as the capacity callback */
graphics {
cargo_capacity: flatbed_truck_1_capacity_switch;
PAPR: flatbed_truck_1_paper;
STEL: flatbed_truck_1_steel;
COPR: flatbed_truck_1_copper;
WOOD: flatbed_truck_1_wood;
default: flatbed_truck_1_goods; // Default to Goods.
}
}

/* Define the road vehicle */
item(FEAT_ROADVEHS, flatbed_truck_4) {
property {
/* Properties common to all vehicle types */
name: string(STR_NAME_FLATBED_TRUCK_4);
climates_available: bitmask(CLIMATE_TEMPERATE, CLIMATE_ARCTIC, CLIMATE_TROPICAL);
road_type: RED_TEST;
introduction_date: date(1926,01,01);
model_life: 65;
/* retire_early not set, use default retirement behaviour */
@@ -2,4 +2,7 @@
STR_GRF_NAME :NML Example NewGRF: Road Vehicle
STR_GRF_DESC :{ORANGE}NML Example NewGRF: Road Vehicle{}{BLACK}This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.{}Original graphics by {SILVER}DanMack, Zephyris, {BLACK}coding by {SILVER}Terkhen, planetmaker.{}{BLACK}This NewGRF defines first-generation flatbed truck.
STR_ERROR_ENGINE_POOL :enable multiple NewGRF engine sets = on
STR_NAME_FLATBED_TRUCK_1 :Flatbed Truck MkI
STR_NAME_FLATBED_TRUCK_1 :Flatbed Truck 1 (Normal Road)
STR_NAME_FLATBED_TRUCK_2 :Flatbed Truck 2 (Electrified Road)
STR_NAME_FLATBED_TRUCK_3 :Flatbed Truck 3 (Yellow Road)
STR_NAME_FLATBED_TRUCK_4 :Flatbed Truck 4 (Unknown, fallback to Red then Road)

0 comments on commit 62cab41

Please sign in to comment.
You can’t perform that action at this time.