Waypoints Air

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Waypoints Air

Post by HackaLittleBit » 26 Dec 2014 02:05

Waypoints for aircrafts.



Reason for patch.
Low flying planes should crash against mountains.;-)
waypoint.png
waypoint.png (135.71 KiB) Viewed 5250 times

Patch List

21964 : Add: Button in airport construction screen.
with function "CmdBuildAirWayPoint" to place air waypoint.
The function is still the same as bouy placing function. "CmdBuildBuoy"

21965 : Add: Enable builting Waypoint air on land.
STATION_BUOY with transmitter.

21966 : Add: Prepare identical to and from flight path
for aircrafts.

21967 : Add: Inserting orders.
Fix: Change Order::GetLocation procedure, 'airport' is false for wapoints.
To do: Solve distance too far problem.

21968 : Add: Make air crafts fly to waypoints.

21969 : Add: Calculate the distance between landing places.
Air waypoints get a little distance bonus.
Don't leave planes stuck on platform when distance too far but send them to hangar.
Conditional orders only to airports.
flag VAF_DEST_TOO_FAR is only removed when situation resolved.(futue use.)

21970 : Fix: Air waypoint button was not added to the Script API.(adf88)

21971 : Fix: WaypointWindow was crashing and displaying wrong vehicle icon. Can't rely on 'BaseStation::facilities' while waypoint is destroyed.(adf88)

21972 : Fix: When building air waypoints, include also the cost of foundation.(adf88)

21973 : Fix-ish: Return more descriptive "Can't build on water" error when trying to place air waypoints on water.(adf88)

21974 : Add: More descriptive error message when trying to create conditional order to waypoint air.

21975 : Add: Don't allow adding conditional orders with destiny too far.

21976 : Change: When checking order distance do it between stations when cloning airplanes.

21977 : Fix: Aircraft distance handles conditinal orders more correctly in loop.
Fix: Typo in IsDestinationTooFar func.


ToDo:
1: Solve circling waypoint when only one left. (now aircaft is stuck because of direction.)
One way to solve this is changing order of entry points but the flight pattern becomes ugly.
Attachments
Waypoints Air svn 27117 v4.3.zip
patch queue
(23.58 KiB) Downloaded 66 times
Waypoints Air _All_ svn 27117 v4.3_.patch
The whole thing together.
(21964 - 21977)
(36.72 KiB) Downloaded 73 times
Last edited by HackaLittleBit on 23 Jan 2015 12:40, edited 10 times in total.

sunshare
Transport Coordinator
Transport Coordinator
Posts: 279
Joined: 10 Oct 2014 00:43

Re: Waypoints Air

Post by sunshare » 26 Dec 2014 02:27

:bow:


Very Good !!! Would love to try the patch but I have no idea how to apply.

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 26 Dec 2014 03:16

HackaLittleBit wrote:Reason for patch.
Low flying planes should crash against mountains.;-)
Also now we can have more control over eyecandy aircraft, police choppers circling cities, cropdusters around farming areas, airship over stadiums, etc... One small bug though, it doesn't seem to work well with aircraft ranges, if I give an aircraft orders to go from say AirportA-waypointB-AirportC, it will always say "next destination out of range", even if distances A-B, B-C, even A-C directly is well within range.

Edit: if the distances are outside the aircraft range, the plane stays on the runway with the "too far to next destination" message, if the distance are within range the plane will take off and fly normally, however in both cases the orders window displays the "next destination out of range" error, it isn't game breaking but slightly confusing since I can't tell if actually out of range when setting orders, only by telling plane to leave hangar and seeing if it actually takes off

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 26 Dec 2014 12:55

Thanks for reporting.
I know what the problem is.
STATION_BUOY is used for this patch.
Station::GetIfValid will not recognize this as a valid station.
And correctly so. a waypoint is not a station.
I don't know what to use.
STATION_BUOY or STATION_WAYPOINT.
I will have a look at it. But it will need time.
The patch won't crash your game so for the time being you can experiment with it.
One known problem I have is that when you leave only one waypoint, the aircrafts get stuck in mid air.
Also there I know what the problem is.(no solution though)


EDIT:
I had again a look at STATION_WAYPOINT and it seams that it is exclusively used for railways.
So in order not to rewrite half the code I opted for STATION_BUOY.
In the end its just a name.
Attatched is quick patch to solve your destination to far problem(for now and not tested!).
Distence between valid stations "airports" should be calculated, not between waypoints.
Now I am going to eat the rest of the turkey.;-)

P.S. Please give me savegame because I have difficulties to reproduce your problem.
Attachments
trunk_3_21936.patch
(1.59 KiB) Downloaded 52 times

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 27 Dec 2014 01:59

Here's a small savegame, r27083 with only the original patches applied.
Attachments
Testapatch Transport, 4th Aug 2040.sav
(257.6 KiB) Downloaded 54 times

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 27 Dec 2014 13:32

Ok thanks.
I will fix it.

The first five patches were basic.
Now we will add whistles and bells.;-)

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 30 Dec 2014 12:45

Ok updated patch.
Some code improvements and experimenting with split up of IsBouy proc.
For now max range works the same for waypoint and airports.
This I will change in the future.
Whistles and bells has to wait a while until code is more mature.

zip file includes seperate patches
plus one patch that combines them all minus trunk_2_21948.patch. (all.diff)
I you use the all.diff you still have to add trunk_2_21948.patch to avoid crashes in old savegames.(FS6196)
Without this patch the game crashes when ship reaches bouy(No flag FACIL_DOCK and waterclass WATER_CLASS_INVALID).
(HackaLittleBit is wondering if this is also the case with oilrigs.) :roll:
EDIT: I am introducing the bug myself see FS6196
Also sprite will not be drawn correct for buoy's
You should keep an eye on the commits from the developers to see if it is nescessary.
See first post for patches.

Please be so kind and test the patch to find bugs.

Doubts and help requested.
1 I do not know if I did the placing of the transmitter sprite correct.
2 Splitting up the IsBouy proc. I would like to know if this is valid code or big s..t!
3 I am thinking of a flag similar to 'FLYING' something like 'FLYINGTOWAYPOINT'. (inbetween ENDTAKEOFF and HELIENDLANDING)
with that flag I do not need to check constantly, if order is 'OT_GOTO_WAYPOINT'.
I tried but crashed game immediately. Question is this worth persuing?

Yeah Eddi now you can shoot. ;-)
Last edited by HackaLittleBit on 01 Jan 2015 10:16, edited 2 times in total.

sunshare
Transport Coordinator
Transport Coordinator
Posts: 279
Joined: 10 Oct 2014 00:43

Re: Waypoints Air

Post by sunshare » 30 Dec 2014 20:39

You should assemble a waypoint with an object for use in water

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 30 Dec 2014 21:00

You mean a bouy?
Why?
In my early tries that was possible and with some modification it is possible now also.
Thing however should not be too easy.
Now you have to build a rock and plant a waypoint on it.
A bit more expensive.;-)

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 02 Jan 2015 04:21

So I applied the all.diff to a clean checkout r27095 and it fails to compile under VS 2013
Visual Studio 2013 build output wrote: Warning 1 warning C4267: 'initializing' : conversion from 'size_t' to 'uint', possible loss of data C:\Users\Eddy Arfik\Documents\Visual Studio 2013\Projects\OpenTTD\svn.openttd.org-27095\src\smallmap_gui.cpp 1103 1 openttd
Warning 2 warning C4267: '=' : conversion from 'size_t' to 'uInt', possible loss of data C:\Users\Eddy Arfik\Documents\Visual Studio 2013\Projects\OpenTTD\svn.openttd.org-27095\src\textfile_gui.cpp 230 1 openttd
Warning 3 warning C4267: '-=' : conversion from 'size_t' to 'uint32', possible loss of data C:\Users\Eddy Arfik\Documents\Visual Studio 2013\Projects\OpenTTD\svn.openttd.org-27095\src\terraform_cmd.cpp 406 1 openttd
Error 4 error C2065: 'STR_ERROR_WAYPOINT_IN_THE_WAY' : undeclared identifier C:\Users\Eddy Arfik\Documents\Visual Studio 2013\Projects\OpenTTD\svn.openttd.org-27095\src\station_cmd.cpp 4079 1 openttd

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5383
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Waypoints Air

Post by PikkaBird » 02 Jan 2015 04:44

I like it. I'll take two.

sunshare
Transport Coordinator
Transport Coordinator
Posts: 279
Joined: 10 Oct 2014 00:43

Re: Waypoints Air

Post by sunshare » 02 Jan 2015 06:12

It could do waypoint for airplanes how are you pictures

http://en.wikipedia.org/wiki/VHF_omnidirectional_range

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 02 Jan 2015 08:17

Eddy Arfik wrote:So I applied the all.diff to a clean checkout r27095 and it fails to compile under VS 2013

Error 4 error C2065: 'STR_ERROR_WAYPOINT_IN_THE_WAY' : undeclared identifier C:\Users\Eddy Arfik\Documents\Visual Studio 2013\Projects\OpenTTD\svn.openttd.org-27095\src\station_cmd.cpp 4079 1 openttd
To me it looks like you have to clean your solution and recompile the whole thing.
STR_ERROR_WAYPOINT_IN_THE_WAY should be located in strings.h
PikkaBird wrote:I like it. I'll take two.
;-)
It will take while before this is ready. I most probably published to early. It is still very experimental!

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 02 Jan 2015 11:07

HackaLittleBit wrote:To me it looks like you have to clean your solution and recompile the whole thing.
I normally do clean solution then rebuild all, that doesn't seem to be the problem. It looks like the all.diff is broken, since I just tried again using the individual patches and it compiled fine.

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 02 Jan 2015 18:27

Eddy Arfik wrote:I normally do clean solution then rebuild all, that doesn't seem to be the problem. It looks like the all.diff is broken, since I just tried again using the individual patches and it compiled fine.
Glad to hear that. I won't post this all diff anymore.

Patch updated!
Back to basics.
Basic flying movement with correct use of waypoints.
IsBuoy IsbuoyTile STATION_BUOY still the same.
Maybe IsWaypoint IsWaypiontTile STATION_WAYPOINT_TINY ?????
It would make the job here easier.;-)
The flags FACIL_DOCK and FACIL_AIRPORT are used to distinguish.
All this can be changed in a much later stadium.

Aircrafts will never use the state machine. Waypoints are NOT airports.
I tried to do something like that but things become unescessary complicated.(slow)
Next step is solving max distence.

Have fun!

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 11 Jan 2015 07:37

I just had a crash using this patch. Steps to reproduce:

1- Build a plane in a helidepot/helistation hangar (shouldn't be possible, but it is)
2- Give the plane an order to travel between the heliport and somewhere else (again, shouldn't be possible but it is)
3- Order the plane to leave the depot
4- Wait a few seconds for game to crash

It looks like the CanVehicleUseStation check is returning true for all aircraft types at helicopter only type facilities, or something like that

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 11 Jan 2015 11:16

Eddy Arfik wrote:I just had a crash using this patch. Steps to reproduce:

1- Build a plane in a helidepot/helistation hangar (shouldn't be possible, but it is)
2- Give the plane an order to travel between the heliport and somewhere else (again, shouldn't be possible but it is)
3- Order the plane to leave the depot
4- Wait a few seconds for game to crash

It looks like the CanVehicleUseStation check is returning true for all aircraft types at helicopter only type facilities, or something like that
I saw your post just now while I was posting the new release.
I had a quick check and was not able to reproduce.
The previous release had more bugs and was very experimental.
From this release on I will keep a bug report.;-)

Added some features:
The distance between airports is now calculated correctly.
Aircrafts check the distance before takeoff.
If too far they will stay at the terminal or will go to hangar if available.
A small range increasing bonus is given when using waypoints because planes don't fly in straight lines anymore.
Conditional orders are only to airports.
See first post.

Eddy Arfik
Transport Coordinator
Transport Coordinator
Posts: 262
Joined: 09 Apr 2014 11:10

Re: Waypoints Air

Post by Eddy Arfik » 12 Jan 2015 08:26

Testing the new version now, everything appears good with the range calculations and I am unable to reproduce the crash I got before.

User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Waypoints Air

Post by adf88 » 12 Jan 2015 10:19

Maybe you can make some use of these:
21954 Fix: Air waypoint button was not added to the Script API.
21955 Fix: WaypointWindow was crashing and displaying wrong vehicle icon. Can't rely on 'BaseStation::facilities' while waypoint is destroyed.
21956 Fix: When building air waypoints, include also the cost of foundation.
21957 Fix-ish: Return more descriptive "Can't build on water" error when trying to place air waypoints on water.

To reproduce the problem fixed by 21955:
1. Build a waypoint (air)
2. Destroy it
3. Click on the label to open waypoint window of the the destroyed waypoint
4. Notice the icon in the lower right corner - it's a train instead of an aircraft
5. Rebuild the waypoint while the window is opened - crash.
Attachments
wpafix.zip
(2.48 KiB) Downloaded 56 times
:] don't worry, be happy and checkout my patches

User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Waypoints Air

Post by HackaLittleBit » 12 Jan 2015 10:41

Great catch!
Thanks.
I will have a look at it.:-)

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 2 guests