Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 62cab41
Show file tree
Hide file tree
Showing 32 changed files with 1,007 additions and 18 deletions.
159 changes: 159 additions & 0 deletions examples/road_vehicle/example_road_vehicle.nml
Expand Up @@ -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]
Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 4 additions & 1 deletion examples/road_vehicle/lang/english.lng
Expand Up @@ -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.