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

AIVehicle.GetLocation not being updated during the travel #2280

Closed
DorpsGek opened this issue Sep 8, 2008 · 3 comments
Closed

AIVehicle.GetLocation not being updated during the travel #2280

DorpsGek opened this issue Sep 8, 2008 · 3 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Sep 8, 2008

jpedreira opened the ticket and wrote:

I'm using r14249-noai.

It seems that AIVehicle.GetLocation is not properly updated during the travel.

You can test it with:
local pos= AIOrder.ResolveOrderPosition(airplane, AIOrder.CURRENT_ORDER) ;
local destination_tile= AIOrder.GetOrderDestination(airplane, pos);
local current_tile= AIVehicle.GetLocation(airplane);
local airport= AIStation.GetStationID(destination_tile);
AILog.Info("Airplane "+AIVehicle.GetName(airplane)+ " going to "+ AIStation.GetName(airport)+", distance: "+AIMap.DistanceSquare(destination_tile, current_tile));

Reported version: trunk
Operating system: Linux


This issue was imported from FlySpray: https://bugs.openttd.org/task/2280
@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2008

jpedreira wrote:

I've patched it for myself. The problem was due to:

  1. In file "src/aircraft_cmd.cpp", in function "AircraftController", the following is done:
    /* If vehicle is in the air, use tile coordinate 0. */
    if (amd->flag & (AMED_TAKEOFF | AMED_SLOWTURN | AMED_LAND)) v->tile = 0;
    which means that, if airplane is flying, tile 0 is used for computations.

  2. In file "src/noai/api/ai_vehicle.cpp", in function "GetLocation", the following is done:
    return ::GetVehicle(vehicle_id)->tile;
    whic means that if airplane is flying, tile 0 is returned!!

To fix it, i've changed last mentioned line for:
if(::GetVehicle(vehicle_id)->tile!= 0)
return ::GetVehicle(vehicle_id)->tile;
else{
int32 x_pos= ::GetVehicle(vehicle_id)->x_pos/TILE_SIZE;
int32 y_pos= ::GetVehicle(vehicle_id)->y_pos/TILE_SIZE;
return TileXY(x_pos, y_pos);
}

If there's any way I can help you, like posting the patch or something... just tell.

Thank you,

Julio Pedreira.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2280#comment4719

@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 9, 2008

jpedreira wrote:

Patch is attached

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/2280#comment4720

@DorpsGek
Copy link
Member Author

TrueBrain closed the ticket.

Reason for closing: Implemented

Commited in r14288.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2280

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant