Aircraft queueing & planespeed

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
Benbo
Transport Coordinator
Transport Coordinator
Posts: 380
Joined: 09 Jan 2006 18:51
Location: UK

Post by Benbo »

That is the one thing I need. You ought to start a topic on it, and see if you could get someone to create a patch for that.
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

about the bug with concorde landing to fast and taxying above runway (if it's what xyz was talking about),
Yeah - apparently at 1000+ MPH @ x8 speeds, the landing is barely a couple of cycles of the game loop, and that throws everything out of whack.

I'm implementing a couple of solutions:

a) Clamping the aircraft to the correct height when it lands.

b) Decreasing the speed of the aircraft as it approaches the airport. It's silly & unrealistic for the aircraft to go from 1000 MPH to a stop in the blink of an eye.
i'v just got an idea:
is it posible to put a "open/close aeroport" button that will keep all the airplains in the queue. this will be usefull when updating the aeroports.
Excellent idea! Start a new thread for this, though: Although I love the idea, that's not part of the purpose of my patch. I may, however, take a look into this if I have time.

Gotta remember when creating language packs that the europeans use "aeroport," and Americans use "airport."
multiply by _patches.aircraft_speed_coeff isn't needed 'cause v->max_speed isn't modified by your patch.
Hmm, it seems you're correct. Fixed.
If you're interested by having plane altitude depending of it's current speed
Not really. Other than the holding pattern, it should be the same as the unpatched OpenTTD, which already has this in place.

The original code is:

Code: Select all

	switch (v->max_speed) {
		case 37: return 162;
		case 74: return 171;
		default: return 180;

Edit: I've uploaded my changes. The supersonic aircraft should now slow down to subsonic before entering the landing sequence, and landed aircraft should be forced to ground level.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
User avatar
Gedemon
Traffic Manager
Traffic Manager
Posts: 150
Joined: 29 Apr 2004 21:53

Post by Gedemon »

problems appear with the (switch...case) with newgrf : planes have more than 3 different speed, and slow planes can fly at same altitude as concorde allowing a "go throught another plane".

but that's not a big problem anyway :)
(and is not related to your patch but defaut ottd)
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Another update - and I'm thinking about doing as a summer project (after the current college semester is over) some more major changes, based upon my experiences with playing Falcon 4.0: Allied Force.

If you've never experienced Falcon 4.0: AF's campaign engine, and you are a flight/combat sim enthusiast - you don't know what you're missing :). This isn't the canned missions of most other flight sims: In AF, the computer is simulating an actual war, and generates missions to accomplish its goals. Each and every plane, vehicle, etc is on a mission trying to accomplish something.

IMHO, they model the the landing system of a real airport quite well - the aircraft controllers give me directions, and since I'm not the only plane landing (I'm part of a real simulated war), they'll have me land as part of a sequence & stuff. I may attempt to duplicate that in future versions of the patch.


Anyways, I needed to do an update of the patch, because the devs decided to completely rework part of the patch UI. This will affect *everybody's* patches, BTW - so if you made a patch, update it!!
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
IN_human
Engineer
Engineer
Posts: 1
Joined: 13 Mar 2006 08:50

Post by IN_human »

Hi, I've just tried to install the patch and got the error msg:

Cannot open file 'C:\Program Files\OpenTTD\data\2ccmap.grf
Where can I get that .grf?

P.S. Noob alert!!! :D
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

The patch is designed to work with the current SVN, which recently added that file. It will not work with the currently released code.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

They changed the way patches work again - and fixed the problem with a bunch of hardcoded numbers :). Patch updated to reflect that.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

Hi,

I found some bugs in your patch. Four times I think you've put code inside an assert(), which is a big no-no, as everything inside an assert will be completely striped out in a release build. Asserts must never contain actual code, only debugging aids. As it stands right now, only debug builds are working correctly.


-- Michael Lutz
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I can only find three:
assert(st->airport_queue->push(st->airport_queue, v)); //near aircraft_cmd.c:900
assert(st->airport_queue->push(st->airport_queue, v)); //near aircraft_cmd.c:1670
assert(st->helicopter_queue->push(st->helicopter_queue, v)); //near aircraft_cmd.c:1675

And yes, that is absolutely broken. My version of the C library has #define assert(x) ((void)0) in non-debug builds. Other versions probably use similar constructs.
Either (1) implement and use verify:

Code: Select all

#ifdef _DEBUG // IIRC, _DEBUG is #defined only for debug builds. If that's not the case, use the appropriate symbol.
#define verify(x) assert(x)
#else
#define verify(x) (x)
#endif
or (2) move the queue manipulations outside the assert.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Post by Michi_cc »

DaleStan wrote:I can only find three:
Yes, you're right. Counting is overrated anyway :wink:

All remaining asserts in the code do look okay.


-- Michael Lutz
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Hi Cobra - can you make sure your patch is up to date with current SVN, and I'll add it to the Integrated Nightly build. Thanks.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Tiberius
Engineer
Engineer
Posts: 86
Joined: 17 Sep 2004 03:15

Post by Tiberius »

Code: Select all

			if (u->type == VEH_Aircraft) {
				/* Take out of airport queue
				*/
				if(u->queue_item != NULL)
				{
					v->queue_item->queue->del(v->queue_item->queue, v);
				}
			}
I guess that inner "v" should actually be "u" instead? :shock:
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Sorry that I haven't been working on my patch. I've been working on other stuff, and just don't have the time. Perhaps in a few months I may get back to working on the patch again, but for now I won't be working on it.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Alright, looks like everybody wants it in the nightlies.

I've taken a bit of time to fix the assertions and the uv problems, and updated it for the latest SVN.

Other than that, no changes.

My idea of redoing the landing sequence, alas, won't come to be this year, as I've been busy with other projects.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

I need help merging some changes (this is the MiniIN code - MiniIn players rejoice, I am working on it!):

Code: Select all

<<<<<<< .mine
			case OT_LOADING:
				SetDParam(0, v->current_order.station);
				SetDParam(1, v->cur_speed * 8 / _patches.aircraft_speed_coeff);
				str = STR_882F_LOADING_UNLOADING;
				break;
=======
			case OT_LOADING: {
				// Vehicle window displays the amount loaded and total capacity while loading in a station
                                const Vehicle *u;
                                uint16 cargo_count=0, cargo_cap=0;

>>>>>>> .theirs

                                u = v->next;

				cargo_count = v->cargo_count + u->cargo_count;
				cargo_cap = v->cargo_cap + u->cargo_cap;

                                if (cargo_count == 0 && !(v->current_order.flags & OF_FULL_LOAD)) {
                                        // Total cargo = 0 and order for current station is not Full Load means we're unloading
                                        str = STR_VEHICLE_UNLOADING;
                                } else {
                                        str = STR_VEHICLE_LOADING;
                                        if (cargo_count > 0) {
                                                // common notation (cargo_count/cargo_cap)*100 won't work because uint16/uint16 returns a uint16
                                                // making the display show either 0% or 100%
                                                SetDParam(0, ((cargo_count*100)/cargo_cap));
                                        } else {
                                                // Can't divide by zero. This shouldn't happen, but in case it does...  display 0%
                                                // if total capacity is 0.
                                                SetDParam(0, 0);
                                        }
                                }
                                break;
                        }
I can't really see what they're doing, it seems like the code's changed pretty radically - suggestions?
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

i have no idea from where you fetched that code.
i'll take a look at miniIN diffs and i hope i can finde something.

Next time please write somewhere where you get that code from, that will help a lot :) i found the part, at least i hope i found the right. Is aircraft_gui.c right?

I'll add the code in some minutes

edit1:
so here it is:
the strings to display are:

Code: Select all

STR_VEHICLE_LOADING                                             :{LTBLUE}Loading {NUM}%  
STR_VEHICLE_UNLOADING                                           :{LTBLUE}Unloading  
STR_VEHICLE_DEPARTING                                           :{LTBLUE}Departing 
But you use

Code: Select all

STR_882F_LOADING_UNLOADING                                      :{LTBLUE}Loading / Unloading
which has no params, but you set two by using SetDParam.
So i can't give yome help here without any further code. For me it looks like the two "SetDParam..." lines are never used, they got set, right but no lang string requires them as far as i can see

to your question about merging

Code: Select all

					....
					// Can't divide by zero. This shouldn't happen, but in case it does...  display 0%  
					// if total capacity is 0.  
					SetDParam(0, 0);  
					}  
				SetDParam(0, v->current_order.station); 
				SetDParam(1, v->cur_speed * 8 / _patches.aircraft_speed_coeff); 
				}  
				break;  
			}
some edits:
btw your code is outdated, you need to update your miniIN working copy :)
Last edited by gigajum on 26 Jun 2006 04:32, edited 5 times in total.
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

yes, aircraft_gui.c, around line 547.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Alright, looks like you're right.

The second parameter is the aircraft's speed indicator, which is carelessley copied from the other case statements, even though it isn't used in this particular string.

Thanks for pointing that out, it'll need to be fixed in both the MiniIN and the trunk patches.

More than likely, I can just dump my code and use theirs - it looks like I don't need any modifications for that section of code.

In addition, I finally got the MiniIN code to compile, so I'm going to create a new savegame with an intercontinential airport for testing my patch with.
btw your code is outdated, you need to update your miniIN working copy
I know, I'll do that also now that I can finish editing my patch.

I hope now to see what the problem is with the largest airport, and should have a MiniIN patch available soon.


EDIT: MiniIN Patch is here! Attached to this post.
Attachments
queue_MiniIN.patch
(46.03 KiB) Downloaded 462 times
Last edited by CobraA1 on 10 Aug 2006 20:31, edited 4 times in total.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

CobraA1 wrote:I hope now to see what the problem is with the largest airport, and should have a MiniIN patch available soon.


EDIT: MiniIN Patch is here! Attached to this post.
Thanks CobraA1. Ive not checked it with the Intercontinental, but have definitely got problems with the Helistation. The helicopters stop in mid air someway short of the helistation, never to proceed further.

Also, your settings vars need to be CONDVARs with the min version number of 35; in vehicle.c you also need to update the min/max version numbers to be 0..34, and 35..SL_MAX_VERSION.

At the mo, I'll hold fire uploading this, as it definitely breaks the helistations. Any chance of an update? Thanks.
Attachments
vehicle.c
Vehicle.c with the changes I think are needed to maintain saveload.
(73.59 KiB) Downloaded 320 times
settings.c
My update to the settings.c file with queueing in.
(79.97 KiB) Downloaded 331 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 38 guests