Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIOrder.SetOrderFlags doesn't always work for ships #8039

Closed
RailwAI opened this issue Mar 19, 2020 · 2 comments
Closed

AIOrder.SetOrderFlags doesn't always work for ships #8039

RailwAI opened this issue Mar 19, 2020 · 2 comments

Comments

@RailwAI
Copy link

@RailwAI RailwAI commented Mar 19, 2020

Version of OpenTTD

OpenTTD 1.10.0-RC1

Expected result

When my AI creates a new freight service with ships from a ship depot (location1), via an oil rig (location2) to an oil refinery, it executes code similar to below when giving the ship (vehicle) its orders. After the following lines I would expect that the second order of the ship is marked as "full load any cargo".

AIOrder.AppendOrder(vehicle, location1, AIOrder.OF_NONE)
AIOrder.AppendOrder(vehicle, location2, AIOrder.OF_NONE);
AIOrder.SetOrderFlags(vehicle, 1, AIOrder.OF_FULL_LOAD_ANY)

Note that location1 and location2 contain a TileIndex. vehicle is the VehicleID of the ship.

Actual result

The second order has no order flags that are visible in the order list of the ship. I'm not sure if it is related to the oil rig or to the ship. I know that similar code (with location1 and location2 being other stations/depots) does work properly with trains and trucks.

A workaround that works and I'll use for my AI is to change the code to

AIOrder.AppendOrder(vehicle, location1, AIOrder.OF_NONE)
AIOrder.AppendOrder(vehicle, location2, AIOrder.OF_FULL_LOAD_ANY)

Steps to reproduce

Install RailwAI version 20 (I'll add a workaround in version 21), and wait until a freight route for ships is made. With the code in the file idea.nut I would expect it to set the order flag to.

@SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Mar 19, 2020

} else if (st->ship_station.tile != INVALID_TILE) {
TILE_AREA_LOOP(t, st->ship_station) {
if (IsDockTile(t) && GetStationIndex(t) == st->index) return t;
}

Problem is there! It's not checking for oil rigs

Somebody with time, the fix is replace that line with
if (IsTileType(t, MP_STATION) && (IsDock(t) || IsOilRig(t)) && GetStationIndex(t) == st->index) return t;
Got no time atm to make a pr.

@SamuXarick
Copy link
Contributor

@SamuXarick SamuXarick commented Mar 20, 2020

This is also affecting AIOrder.GerOrderDestination

SamuXarick added a commit to SamuXarick/OpenTTD that referenced this issue Mar 20, 2020
LordAro pushed a commit to LordAro/OpenTTD that referenced this issue Mar 30, 2020
douiwby pushed a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants