## News:

Use the "Forum Search"

Started by jamespetts, July 28, 2012, 01:03:31 AM

0 Members and 1 Guest are viewing this topic.

#### jamespetts

Sorry to trouble people: I am looking to code a minimum runway length parameter for aircraft for Simutrans-Experimental, and should appreciate any tips in calculating the length in tiles of a runway. For the runway on which an aircraft is to land, suchen+1) - touchdown seems to be the correct formula, but I cannot quite work out what the figure for takeoff should be. Any tips would be much appreciated!

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

#### prissi

There is no precalculated runway length. If the plane speed is high enough (1/3 if memory servers me right) it takes off. If the end of runway is reached, it will take off too. However, from takeoff position there is one one direction, thus countin runway tiles should be easy.

Also your touchdow formula might be wrong one tile in less commoon terrain height.

#### jamespetts

Thank you for the reply. I'm more interested in simply getting the length of the actual runway at an airport than the length of the runway in an aircraft's route. As you might see from the code/other post, I have found a way of doing it, but the difficulties with that method are: (1) I cannot find a way of recalculating the runway length every time that an aircraft circles to try to land at an airport with too short a runway, so a player who extends the runway to solve the problem has to open the aircraft's schedule manually and close it again to re-set the calculation; and (2) there is no way of clicking on the airport and finding out the length of its runway. It would be easier if there was a way of writing a uint16 haltestelle_t::get_runway_length() method, but I'm not quite sure how to go about doing that. Airports with multiple runways would potentially complicate this, but from what I understand, a single airport/terminal can only make use of one runway at a time in the current code in any event, so this might not be a particular problem.

I'm not sure that I follow your point about my touchdown formula  what do you mean "one tile in less common terrain height" here?

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

#### Ters

A single terminal can use multiple runways, at least one for landing and one for take-off, controlled by one-way signs. If the runways are at different sides of the terminal, but equidistant from it, I would assume that planes, in the absence of signs, would use the runway in the direction their coming from or going to, as it would be yield the shortest overall route.

#### jamespetts

Ahh, thank you: AEO already tipped me off about one way runway signs. Looking into integrating that into Pak128.Britain-Ex...

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

#### prissi

I would also forbid to take off if the landing strip is too short.

#### jamespetts

Prissi,

that seems sensible - but is there an easier way of measuring runway length than I have so far managed...?

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

#### prissi

You could use first find_route for a suitable runway for takeoff. Then do the same for landing (using reverse signs) for the target location. Then you can just use the normal flight modus (which I would recommend, as its logic is very delicate, means easy to break).

#### Dwachs

You might be interested in this (old) patch

http://forum.simutrans.com/index.php?topic=7744.msg73872#msg73872

where I implemented a min-length of three tiles for runways. See

bool aircraft_t::can_takeoff_here
Parsley, sage, rosemary, and maggikraut.

#### dom700

Quote from: prissi on July 29, 2012, 06:51:35 PM
I would also forbid to take off if the landing strip is too short.

I hope you realise that an airport with one runway for take-off and none for landing works perfectly fine. (Probably a bug)

#### Fabio

Is this feature desirable for standard too? I would say so, IMHO.
Otherwise there is no need for runaways longer than 3 tiles.
A no route error could be triggered, maybe changed to no runaway found.

#### prissi

Given the fact that most users stuggle to built any airport all all, such a feature could be at most optional. Balancing a route is much more difficult (and more transport simulation) than just making longer runways.

#### jamespetts

Dwachs and Prissi,

thank you both very much for your suggestions: I agree with Prissi that using find_route is the better way of doing it, and I have been looking into Dwachs' patch for these purposes, which is helpful. However, I am having trouble making the runway length counter part of it work, and I wonder whether Dwachs might be able to give me some pointers as to where I might be going wrong. Here is the code as I have implemented it:

`// this routine is called by find_route, to determined if we reached a destinationbool aircraft_t::ist_ziel(const grund_t *gr,const grund_t *) const{ if(state!=looking_for_parking) { // search for the end of the runway const weg_t *w=gr->get_weg(air_wt); if(w  &&  w->get_besch()->get_styp()==1) { // ok here is a runway ribi_t::ribi ribi= w->get_ribi_unmasked(); int success = 1; if(ribi_t::ist_einfach(ribi)  &&  (ribi&approach_dir)!=0) { // pointing in our direction // Check for length const uint16 min_runway_length_meters = besch->get_minimum_runway_length(); const uint16 min_runway_length_tiles = min_runway_length_meters / welt->get_settings().get_meters_per_tile(); for(uint16 i = 0; i <= min_runway_length_tiles; i ++) { if (const ribi_t::ribi dir = ribi & approach_dir & ribi_t::nsow[i]) { const grund_t* gr2 = welt->lookup_kartenboden(gr->get_pos().get_2d() + koord(dir)); if(gr2) { const weg_t* w2 = gr2->get_weg(air_wt); if( w2 && w2->get_besch()->get_styp() == 1 && ribi_t::ist_einfach(w2->get_ribi_unmasked()) && (w2->get_ribi_unmasked() & approach_dir) != 0 ) { // All is well - there is runway here. continue; } else { goto bad_runway; } } else { goto bad_runway; } } else {bad_runway: // Reached end of runway before iteration for total number of minimum runway tiles exhausted: // runway too short. success = 0; break; } } //return true; return success; } } } else { // otherwise we just check, if we reached a free stop position of this halt if(gr->get_halt()==target_halt  &&  target_halt->is_reservable(gr,cnv->self)) { return 1; } } return 0;}`

The problem is that it fails to recognise the tiles as runway during the for(uint16 i = 0; i <= min_runway_length_tiles; i ++)  loop, even though the tests are those copied from the original code. I am slightly confused as to what I am doing wrong here, and should very much appreciate any guidance.

Also, is there an sensible way of telling the UI whether it is the takeoff or the landing runway that is too short?

Thank you very much for your help.