FS#6514 - Missing documentation for AIVehicle::RefitVehicle
Wagon unattached to engine may not be refitted, even if other preconditions are fullfilled.
Note that wagon in depot, unattached to an engine will not always return false for IsValidVehicle(vehicle_id) (note also AIVehicle.MoveWagon must be able to move newly constructed wagon, so it is tricky whatever lone wagon should return true for IsValidVehicle).
It seems that presence of engine changes whatever lone wagon IsValidVehicle but it is changing whatever lone wagon may be refitted.
I attached also debug AI used to test game behaviour.
This task depends upon