Overrides the rail pathfinder's _Cost function to add a penalty for level crossings. More...
Public Member Functions | |
function | GetTilesAroundTown (town_id, width, height) |
Get a TileList around a town. | |
function | BuildSingleRailStation (is_source, platform_length, route_data, station_data, rail_manager) |
Build a single (one-lane) rail station at a town or an industry. | |
function | CanBuildSingleRailStation (tile, direction, platform_length, station_data) |
Check whether a single rail station can be built at the given position. | |
function | BuildRailStation (is_source, lanes, platform_length, route_data, station_data, rail_manager) |
Build a rail station at a town or an industry. | |
function | CanBuildRailStation (tile, lanes, direction, platform_length, station_data) |
Determine whether a rail station can be built at a given place. | |
function | BuildRail (head1, head2, railbridges) |
Build a rail line between two given points. | |
function | InternalBuildRail (head1, head2, railbridges, recursiondepth) |
Build a rail line between two given points. | |
function | RetryRail (prevprev, pp1, pp2, pp3, head1, railbridges, recursiondepth) |
Retry building a rail track after it was interrupted. | |
function | BuildPassingLaneSection (near_source, train_length, station_data, rail_manager) |
Build a passing lane section between the current source and destination. | |
function | CanBuildPassingLaneSection (centre, direction, reverse, train_length) |
Determine whether a passing lane section can be built at a given position. | |
function | BuildAndStartTrains (number, length, engine, wagon, ordervehicle, group, cargo, station_data, engineblacklist) |
Build and start trains for the current route. | |
function | MailWagonWorkaround (mailwagon, firstwagon, trainengine, crg) |
A workaround for refitting the mail wagon separately. | |
function | RemoveRailLine (start_tile, rail_manager) |
Remove a continuous segment of rail track starting from a single point. | |
function | AreRailTilesConnected (tilefrom, tileto) |
Determine whether two tiles are connected with rail directly. | |
function | DeleteRailStation (sta, rail_manager) |
Delete a rail station together with the rail line. | |
function | ElectrifyRail (start_tile, rail_manager) |
Upgrade a segment of normal rail to electrified rail from a given starting point. | |
function | GetRailStationPlatformLength (sta) |
Get the platform length of a station. | |
function | AttachMoreWagons (vehicle, rail_manager) |
Attach more wagons to a train after it has been sent to the depot. |
Static Public Member Functions | |
static function | ChooseWagon (cargo, blacklist) |
Choose a rail wagon for the given cargo. | |
static function | ChooseTrainEngine (cargo, distance, wagon, num_wagons, blacklist) |
Choose a train locomotive. | |
static function | TrainEngineValuator (engine, weight, max_speed, money) |
A valuator function for scoring train locomotives. |
Overrides the rail pathfinder's _Cost function to add a penalty for level crossings.
DISABLED. Now part of our pathfinder code.
function WormRailPathFinder::_Cost(path, new_tile, new_direction, self) { local cost = ::Rail._Cost(path, new_tile, new_direction, self); if (AITile.HasTransportType(new_tile, AITile.TRANSPORT_ROAD)) cost += self._cost_level_crossing; return cost; } Define the WormRailBuilder class which handles trains.
function WormRailBuilder::AreRailTilesConnected | ( | tilefrom | , |
tileto | |||
) |
Determine whether two tiles are connected with rail directly.
tilefrom | The first tile to check. |
tileto | The second tile to check. |
function WormRailBuilder::AttachMoreWagons | ( | vehicle | , |
rail_manager | |||
) |
Attach more wagons to a train after it has been sent to the depot.
vehicle | The VehicleID of the train. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::BuildAndStartTrains | ( | number | , |
length | , | ||
engine | , | ||
wagon | , | ||
ordervehicle | , | ||
group | , | ||
cargo | , | ||
station_data | , | ||
engineblacklist | |||
) |
Build and start trains for the current route.
number | The number of trains to be built. |
length | The number of wagons to be attached to the train. |
engine | The EngineID of the locomotive. |
wagon | The EngineID of the wagons. |
ordervehicle | The vehicle to share orders with. Null, if there is no such vehicle. |
group | The vehicle group this train should be part of. |
cargo | The cargo to transport. |
station_data | A WormStation class object with info about the stations between which rail is being built. |
engineblacklist | The blacklist of engines to which bad engines will be added. |
function WormRailBuilder::BuildPassingLaneSection | ( | near_source | , |
train_length | , | ||
station_data | , | ||
rail_manager | |||
) |
Build a passing lane section between the current source and destination.
Builder class variables used: stasrc, stadst
near_source | True if we're building the first passing lane section. (the one closer to the source station) |
train_length | The maximum train length in tiles that should fit (should be at least 3). |
station_data | A WormStation class object with info about the stations between which rail is being built. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::BuildRail | ( | head1 | , |
head2 | , | ||
railbridges | |||
) |
Build a rail line between two given points.
head1 | The starting points of the rail line. |
head2 | The ending points of the rail line. |
railbridges | The list of railbridges. If we need to build a bridge it will be added to this list. |
function WormRailBuilder::BuildRailStation | ( | is_source | , |
lanes | , | ||
platform_length | , | ||
route_data | , | ||
station_data | , | ||
rail_manager | |||
) |
Build a rail station at a town or an industry.
is_source | True if we are building the source station. |
lanes | The number of lanes (platforms). Currently only 1 or 2 is supported. |
platform_length | The length of the proposed station's platform. |
route_data | A WormRoute class object containing info about the route. |
station_data | A WormStation class object containing info about the station. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::BuildSingleRailStation | ( | is_source | , |
platform_length | , | ||
route_data | , | ||
station_data | , | ||
rail_manager | |||
) |
Build a single (one-lane) rail station at a town or an industry.
Builder class variables used: crg, src, dst, srcplace, dstplace, srcistown, dstistown, statile, stafront, depfront, frontfront, statop, stationdir Builder class variables set: stasrc, stadst, homedepot
is_source | True if we are building the source station. |
platform_length | The length of the new station's platform. |
route_data | A WormRoute class object containing info about the route. |
station_data | A WormStation class object containing info about the station. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::CanBuildPassingLaneSection | ( | centre | , |
direction | , | ||
reverse | , | ||
train_length | |||
) |
Determine whether a passing lane section can be built at a given position.
centre | The centre tile of the proposed passing lane section. |
direction | The direction of the proposed passing lane section. |
reverse | True if we are trying to build a flipped passing lane section. |
train_length | The maximum train length in tiles that should fit (should be at least 3). |
Design of a passing lane
function WormRailBuilder::CanBuildRailStation | ( | tile | , |
lanes | , | ||
direction | , | ||
platform_length | , | ||
station_data | |||
) |
Determine whether a rail station can be built at a given place.
tile | The tile to be checked. |
lanes | The number of lanes (platforms). Currently only 1 or 2 is supported. |
direction | The direction of the proposed station. |
platform_length | The length of the proposed station's platform. |
station_data | WormStation class object where the build info will be store (should be non null when called). |
function WormRailBuilder::CanBuildSingleRailStation | ( | tile | , |
direction | , | ||
platform_length | , | ||
station_data | |||
) |
Check whether a single rail station can be built at the given position.
Builder class variables set: statop, stabotton, statile, stafront, depfront, frontfront
tile | The tile to be checked. |
direction | The direction of the proposed station. |
platform_length | The length of the proposed station's platform. |
station_data | WormStation class object where the build info will be store (should be non null when called). |
|
static |
Choose a train locomotive.
cargo | The cargo to carry. |
distance | The distance to be traveled. |
wagon | The EngineID of the wagons to be pulled. |
num_wagons | The number of wagons to be pulled. |
blacklist | A list of engines that cannot be used. |
|
static |
Choose a rail wagon for the given cargo.
cargo | The cargo which will be transported by te wagon. |
function WormRailBuilder::DeleteRailStation | ( | sta | , |
rail_manager | |||
) |
Delete a rail station together with the rail line.
Builder class variables used and set:
sta | The StationID of the station to be deleted. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::ElectrifyRail | ( | start_tile | , |
rail_manager | |||
) |
Upgrade a segment of normal rail to electrified rail from a given starting point.
Tiles which are reachable by a train from a given starting point are electrified, including stations and depots. This function is not static.
start_tile | The starting point from which rails are electrified. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::GetRailStationPlatformLength | ( | sta | ) |
Get the platform length of a station.
sta | The StationID of the station. |
function WormRailBuilder::GetTilesAroundTown | ( | town_id | , |
width | , | ||
height | |||
) |
Get a TileList around a town.
town_id | The TownID of the given town. |
width | The width of the proposed station. |
height | The height of the proposed station. |
function WormRailBuilder::InternalBuildRail | ( | head1 | , |
head2 | , | ||
railbridges | , | ||
recursiondepth | |||
) |
Build a rail line between two given points.
head1 | The starting points of the rail line. |
head2 | The ending points of the rail line. |
railbridges | The list of railbridges. If we need to build a bridge it will be added to this list. |
recursiondepth | The recursion depth used to catch infinite recursions. |
function WormRailBuilder::MailWagonWorkaround | ( | mailwagon | , |
firstwagon | , | ||
trainengine | , | ||
crg | |||
) |
A workaround for refitting the mail wagon separately.
mailwagon | The mail wagon to be refitted. |
firstwagon | The wagon to which the mail wagon is attached. |
trainengine | The locomotive of the train, used to move the wagons. |
crg | The cargo which the mail wagon will be refitted to. |
function WormRailBuilder::RemoveRailLine | ( | start_tile | , |
rail_manager | |||
) |
Remove a continuous segment of rail track starting from a single point.
This includes depots and stations, in all directions and braches. Basically the function deletes all rail tiles which are reachable by a train from the starting point. This function is not static.
start_tile | The starting point of the rail. |
rail_manager | The WormRailManager class object. |
function WormRailBuilder::RetryRail | ( | prevprev | , |
pp1 | , | ||
pp2 | , | ||
pp3 | , | ||
head1 | , | ||
railbridges | , | ||
recursiondepth | |||
) |
Retry building a rail track after it was interrupted.
The last three pieces of track are removed, and then pathfinding is restarted from the other end.
prevprev | The last successfully built piece of track. |
pp1 | The piece of track before prevprev. |
pp2 | The piece of track before pp1. |
pp3 | The piece of track before pp2. It is not removed. |
head1 | The other end to be connected. |
railbridges | The list of railbridges. If we need to build a bridge it will be added to this list. |
recursiondepth | The recursion depth used to catch infinite recursions. |
|
static |
A valuator function for scoring train locomotives.
engine | The engine to be scored. |
weight | The weight to be pulled. |
max_speed | The maximum speed allowed. |
money | The amount of money the company has. |