OpenTTD

Tasklist

FS#4024 - AIOrder.AppendOrder fails on "goto nearest depot and stop" order

Attached to Project: OpenTTD
Opened by Attila7 (Attila7) - Tuesday, 10 August 2010, 13:23 GMT
Last edited by Remko Bijker (Rubidium) - Tuesday, 10 August 2010, 16:45 GMT
Type Bug
Category Script → NoAI
Status Closed
Assigned To No-one
Operating System All
Severity High
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I believe there is a bug in the way "go to nearest depot" orders are handled.
Line 528 of order_cmd.cpp reads:
if (new_order.GetDepotActionType() != ODATFB_NEAREST_DEPOT) {

It appears that this attempts to test if the order contains a "go to nearest depot" order and
skip the depot validation test if so. However if the the order also contains other bits,
such as a "stop in depot" order, the above test will be true and the code will attempt to
validate tile 0 as a depot.

Tile 0 is forced into an AppendOrder call at line 389 of ai_order.cpp if the order contains
a "go to nearest depot" order.

I think line 528 should be changed to:
if (!(new_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT)) {

This will correctly test the relevant bit and skip the depot validation.

As the code stands now, it succeeds most of the time, because the validation of tile 0 will fail
depending on what command was last executed and by what AI. It is essentially a garbage test.
This task depends upon

Closed by  Remko Bijker (Rubidium)
Tuesday, 10 August 2010, 16:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r20441

Loading...