This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extending NewGRF APIs - impedance mismatch | |
Term borrowed from https://en.wikipedia.org/wiki/Object%E2%80%93relational_impedance_mismatch | |
In no particular order | |
* not many OpenTTD devs familiar with grf spec | |
* so designing and reviewing can be hard | |
* some of the requests from grf authors are misguided | |
* interacting with newgrf authors can involve blah blah politics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (FEAT_TRAINS, SELF, intermodal_car_switch_colour_mapping_not_a_cargo_sprinter, vehicle_is_flipped) { | |
1: return base_sprite_2cc + 16 * company_colour1 + company_colour2; | |
return base_sprite_2cc + 16 * company_colour2 + company_colour1; | |
} | |
switch (FEAT_TRAINS, SELF, intermodal_car_switch_colour_mapping_cargo_sprinter, 0) { | |
return base_sprite_2cc + 16 * company_colour2 + company_colour1; | |
} | |
switch (FEAT_TRAINS, PARENT, intermodal_car_switch_colour_mapping_force_if_cargo_sprinter, vehicle_type_id) { | |
3000: return intermodal_car_switch_colour_mapping_cargo_sprinter; | |
return intermodal_car_switch_colour_mapping_not_a_cargo_sprinter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (FEAT_TRAINS, SELF, intermodal_car_switch_colour_mapping_not_a_cargo_sprinter, vehicle_is_flipped) { | |
1: return base_sprite_2cc + 16 * company_colour1 + company_colour2; | |
return base_sprite_2cc + 16 * company_colour2 + company_colour1; | |
} | |
switch (FEAT_TRAINS, PARENT, intermodal_car_switch_colour_mapping_force_if_cargo_sprinter, vehicle_type_id) { | |
3000: base_sprite_2cc + 16 * company_colour2 + company_colour1; | |
return intermodal_car_switch_colour_mapping_not_a_cargo_sprinter; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Newgrf vehicles TL;DR | |
Each vehicle is an instance of a model type. | |
Each model type is an instance of one of the base game vehicles (engine, wagon, dual-head engine). | |
Vehicle instances have properties, which have gameplay effects. | |
Properties are generally initialised when a vehicle is built. | |
Many properties are mutable. | |
Properties are mutable via callbacks which are triggered on specific game events. | |
Vehicles can use logic in callbacks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spriteset(ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_unflipped, "generated/graphics/intermodal_default_box_DFLT_16px.png") { | |
spriteset_template_asymmetric_unreversed_4_8_unflipped(10 + 0, NOANIM) | |
} | |
spriteset(ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_flipped, "generated/graphics/intermodal_default_box_DFLT_16px.png") { | |
spriteset_template_asymmetric_reversed_4_8_flipped(10 + 0, NOANIM) | |
} | |
switch (FEAT_TRAINS, SELF, switch_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0, vehicle_is_flipped) { | |
1: return ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_flipped; | |
return ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_unflipped; | |
} |
This file has been truncated, but you can view the full file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Automatically generated by GRFCODEC. Do not modify! | |
// (Info version 32) | |
// Escapes: 2+ 2- 2< 2> 2u< 2u> 2/ 2% 2u/ 2u% 2* 2& 2| 2^ 2sto = 2s 2rst = 2r 2psto 2ror = 2rot 2cmp 2ucmp 2<< 2u>> 2>> | |
// Escapes: 71 70 7= 7! 7< 7> 7G 7g 7gG 7GG 7gg 7c 7C | |
// Escapes: D= = DR D+ = DF D- = DC Du* = DM D* = DnF Du<< = DnC D<< = DO D& D| Du/ D/ Du% D% | |
// Format: spritenum imagefile depth xpos ypos xsize ysize xrel yrel zoom flags | |
0 * 4 \d171529 | |
1 * 6462 14 "C" "INFO" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spriteset(ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_unflipped, "generated/graphics/intermodal_default_box_DFLT_16px_.png") { | |
spriteset_template_asymmetric_unreversed_4_8_unflipped(10 + 0, NOANIM) | |
} | |
spriteset(ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_flipped, "generated/graphics/intermodal_default_box_DFLT_16px_.png") { | |
spriteset_template_asymmetric_reversed_4_8_flipped(10 + 0, NOANIM) | |
} | |
switch (FEAT_TRAINS, SELF, switch_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0, vehicle_is_flipped) { | |
1: return ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_flipped; | |
return ss_spritelayer_cargos_intermodal_cars_default_16px_box_DFLT_0_unflipped; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# autopep8 | |
container_type_gestalt_mapping = {'box': [ | |
IntermodalBox16px, | |
IntermodalBox24px, | |
IntermodalBox32px | |
], | |
'bulk': [ | |
IntermodalFlatCar16pxStandard, | |
IntermodalFlatCar24pxStandard, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1: return custom_wagon_recolour_sprites + 16 * 0 /* recolour set */ + company_colour1; | |
2: return custom_wagon_recolour_sprites + 16 * 1 /* recolour set */ + company_colour2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (FEAT_TRAINS, SELF, switch_alt_var_41_match_ids, STORE_TEMP(var[0x61, 0, 0x0000FFFF, 0xC6], 0)) { | |
return switch_alt_var_41_match_ids_0; | |
} | |
switch (FEAT_TRAINS, SELF, switch_alt_var_41_position_in_vehid_chain_multiple_ids_127, [STORE_TEMP(-127, 0x10F), switch_alt_var_41_match_ids()]) { | |
return 126; | |
} | |
switch (FEAT_TRAINS, SELF, switch_alt_var_41_position_in_vehid_chain_multiple_ids_126, [STORE_TEMP(-126, 0x10F), switch_alt_var_41_match_ids()]) { | |
1: switch_alt_var_41_position_in_vehid_chain_multiple_ids_127; | |
return 125; | |
} |