Code: Select all
/* This file is used to determine which vehicles can be attached to which vehicles.
* First the ID of the attaching vehicle is detected:
* Engines will always be allowed to attach
* Regular wagons and coaches will only be attached to regular engines
* Unit wagons are only allowed behind other Unit wagons and the front heads of MUs
*/
/*
* Regular wagons/coaches
*/
//Check vehicle ID of the vehicle in front
//Wagons and coaches can only be attached to normal engines and other wagons and coaches, but not to Multiple Unit vehicles
switch(FEAT_TRAINS, SELF, switch_can_attach_wagon, [STORE_TEMP(-1, 0x10F), var[0x61, 0, 0x0000FFFF, 0xC6]]) {
1000..1999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Steam Railbus, allow
2000..2999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Diesel Railbus, allow
3000..3999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Electric Railbus, allow
4000..4999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Steam, allow
5000..5999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Diesel, allow
6000..6999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Electric, allow
7000..7999: string(str_cannot_attach_wagon_to_MU); //DMU, disallow
8000..8999: string(str_cannot_attach_wagon_to_MU); //EMU, disallow
9000..9999: string(str_cannot_attach_wagon_to_MU); //Multi Unit Metro, disallow
10000..10999: string(str_cannot_attach_wagon_to_MU); //Multi Unit Maglev, disallow
11000..11999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Coaches, allow
12000..12999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Wagons, allow
13000..13999: string(str_cannot_attach_wagon_to_Unit_Wagon); //Unit Wagons, disallow
14000..14999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Single Unit Metro, allow
15000..15999: string(str_cannot_attach_wagon_to_MU); //SMU, disallow
16000..16999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Single Unit Maglev, allow
}
/*
* Unit Wagon
*/
//Check if the Unit wagon follows the front head
switch(FEAT_TRAINS, SELF, switch_can_attach_Unit_to_MU_head, [STORE_TEMP(-1, 0x10F), var[0x61, 0xC8]]) {
0xFE: string(str_cannot_attach_Unit_wagon_to_back); //Back head, disallow
0xFF: string(str_cannot_attach_Unit_wagon_to_back); //Back head, disallow
CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Front head, allow
}
//Check vehicle ID of the vehicle in front in case this is a unit wagon
//Unit wagons can be attached to Multiple Unit vehicles, but not to engines and other wagons/coaches
switch(FEAT_TRAINS, SELF, switch_can_attach_unit, [STORE_TEMP(-1, 0x10E), var[0x61, 0, 0x0000FFFF, 0xC6]]) {
1000..1999: string(str_cannot_attach_Unit_wagon_to_engine); //Steam Railbus, disallow
2000..2999: string(str_cannot_attach_Unit_wagon_to_engine); //Diesel Railbus, disallow
3000..3999: string(str_cannot_attach_Unit_wagon_to_engine); //Electric Railbus, disallow
4000..4999: string(str_cannot_attach_Unit_wagon_to_engine); //Steam, disallow
5000..5999: string(str_cannot_attach_Unit_wagon_to_engine); //Diesel, disallow
6000..6999: string(str_cannot_attach_Unit_wagon_to_engine); //Electric, disallow
7000..7999: switch_can_attach_Unit_to_MU_head; //DMU, go to Head-switch
8000..8999: switch_can_attach_Unit_to_MU_head; //EMU, go to Head-switch
9000..9999: switch_can_attach_Unit_to_MU_head; //Multi Unit Metro, go to Head-switch
10000..10999: switch_can_attach_Unit_to_MU_head; //Multi Unit Maglev, go to Head-switch
11000..11999: string(str_cannot_attach_Unit_wagon_to_wagon); //Coaches, allow
12000..12999: string(str_cannot_attach_Unit_wagon_to_wagon); //Wagons, allow
13000..13999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Unit Wagons, disallow
14000..14999: string(str_cannot_attach_Unit_wagon_to_engine); //Single Unit Metro, allow
15000..15999: switch_can_attach_Unit_to_MU_head; //SMU, go to Head-switch
16000..16999: string(str_cannot_attach_Unit_wagon_to_engine); //Single Unit Maglev, allow
}
/* Check vehicle ID to determine which case we have.
* Engines are always allowed to be attached
* Wagons depend on vehicle in front of it
*/
switch(FEAT_TRAINS, SELF, switch_can_attach_vehicle, vehicle_type_id) {
1000..1999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Steam Railbus, always allow
2000..2999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Diesel Railbus, always allow
3000..3999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Electric Railbus, always allow
4000..4999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Steam, always allow
5000..5999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Diesel, always allow
6000..6999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Electric, always allow
7000..7999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //DMU, always allow
8000..8999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //EMU, always allow
9000..9999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Multi Unit Metro, always allow
10000..10999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Multi Unit Maglev, always allow
11000..11999: switch_can_attach_wagon; //Coaches, go to Regular-switch
12000..12999: switch_can_attach_wagon; //Wagons, go to Regular-switch
13000..13999: switch_can_attach_unit; //Unit Wagons, go to Unit-switch
14000..14999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Single Unit Metro, always allow
15000..15999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //SMU, always allow
16000..16999: CB_RESULT_ATTACH_ALLOW_IF_RAILTYPES; //Single Unit Maglev, always allow
}
}