Bugs with larger airports - READ

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

Post Reply
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Bugs with larger airports - READ

Post by Darkvater »

Recently some people have contacted me on IRC having bugs with airports since using savegames through several nightly builds.

I would like to give a brief statement about it, the cause of these problems, and a possible solution for the technical savvy ones.

Of course, using nightly builds, you accept that things can break, but we don't like that, that's why I tried to solve the people who contacted me with their problems (regarding airports).

Background
When a airport is built, it is given an index which is saved in Station *st->airport_type. This index tells the game what type of airport it is.
In the good old days without bigger airports, the code was as follows:

Code: Select all

AT_SMALL = 0,
AT_LARGE = 1,
AT_HELIPORT = 2,	
AT_OILFIELD = 3,
In the initial release of bigger airports, the indexes were as follows:

Code: Select all

AT_SMALL = 0,
AT_LARGE = 1,
AT_METROPOLITAN = 2,
AT_INTERNATIONAL = 3,
AT_HELIPORT = 4,
AT_OILFIELD = 5,
Unfortunately in the first release of larger airports, I forgot to update HELIPORT from 2-4 and OILFIELD from 3-5 (possible bug #1).

I then realized, why screw up the index, so I changed it back (OILRIG is 5, cause, well, it's special):

Code: Select all

AT_SMALL = 0,
AT_LARGE = 1,
AT_HELIPORT = 2,
AT_METROPOLITAN = 3,
AT_INTERNATIONAL = 4,
AT_OILRIG = 5
This combined with the infinity possibility of building new airports across multiple nightly builds is possible bug #3

Solution
For those of you that have programming knowledge, this can be easily solved. I added a concept fix for this, you can get it at http://darkvater.no-ip.com/temp/ottd/airportsvn_fix.c. Add this function to aircraft_cmd.c, somewhere just above AirportGoToNextPosition() (line 1800). Start the game WITHOUT the title screen, load the game, and see how this function is called exactly once. All code that actually does something is commented out, since it is custom which one to use. When done, and all seems ok, save the game, remove the function(call) and happily enjoy an unbugged game again.
To find out what to change: _stations[v->u.air.targetairport].airport_type This tells what type of airport the airplane accepts. So if target airport is a metropolitan one, it should be 3, and you should uncomment the appropiate line. Hopefully you won't have too much to fix. If you have many airplanes, uncomment return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT); on line 393 of aircraft_cmd.c to be able to pause all airplanes mid-air, and concentrate on a single one.

Solution for the non-programmer
If you really cannot live without your savegame, send it to me, and I'll see what I can do. Please no test-games, and the such, cause those are not worth the trouble and time I have to put in it to solve it.

All games started with an SVN version after 1 june, should not have any bugs for this.

In accordance with this, I have decided to release nightly builds with code-checking still in it. This means that if you get a bug, you will most likely not be able to play further, but it will result in the discovery of bugs a lot sooner
Last edited by Darkvater on 10 Jun 2004 22:12, edited 1 time in total.
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."
soundman
Engineer
Engineer
Posts: 23
Joined: 25 Apr 2004 17:46

Post by soundman »

[extended howto]
Insert the new function under "UpdateOldAircraft()" and move "AircraftEventHandler" and "Aircraft_Tick" to the bottom off the file.

Then insert "FixSVNVersion();" just before "AirportGoToNextPosition"
[/extended howto]

Thanx for this workaround :D
[edit]
Created a patch: http://www.xs4all.nl/~rosdorff/aircraft_cmd_patch
[/edit]
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Creating a patch is unncessary, since this code will never be in an SVN or release version :)

I was a bit lazy about the function :). You can just declare the function somewhere above, without moving all the code around. I think that is a lot better
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."
soundman
Engineer
Engineer
Posts: 23
Joined: 25 Apr 2004 17:46

Post by soundman »

Darkvater wrote:Creating a patch is unncessary, since this code will never be in an SVN or release version :)

I was a bit lazy about the function :). You can just declare the function somewhere above, without moving all the code around. I think that is a lot better
msvc complained about UpdateOldAircraft() if FixSVN was at the bottom. Didn't knew how to handle that. Thats the reason of the bug shuffle :)

Patch is for other programming noobs like me who want to rescue their savegame...
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

You do realize you still have to uncomment the necessary lines to fix stuff? ;)

Otherwise, a patch can never hurt though. I figured if someone thinks he/she is capable enough to fix their savegame, they can handle a little programming once they know what's wrong, and how to fix it :)
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."
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 12 guests