Patch: Upgrade airports

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
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Patch: Upgrade airports

Post by cirdan » 20 Jan 2008 12:20

Hi,

I've made a patch that allows airports to be upgraded, that is, it allows to replace an airport in a station with another. It works much like railroad stations: you build a station over an existing one and the old one gets demolished. Specifically, to use this patch you must select an airport to be built and place it overlapping (partially or totally) an existing one, which will be removed and replaced atomically. The usual restrictions apply, so you must be on good terms with the local authority, the tiles to be used must be clear (except those belonging to the old airport), etc.

The advantages of this patch are:

- Easier interface: fewer clicks for the same job.

- Atomicity: the town no longer has a chance to build roads or buildings between removal and rebuilding of an airport (very annoying).

- Local authority ratings are checked before execution starts, so you won't find that you've demolished an airport and now the town authority doesn't allow you to replace it (nor to rebuild the old one).

I've found another patch to this same end, but it's a bit old and no longer applies cleanly against trunk (and it seemed to have some problems), so I've coded a new one.

This patch can be coupled with my airport-close patch for easiest replacing of airports. :-)

----------------
EDIT: Current status:
Patches against: 0.6.0 | 0.6.1 | 0.7.0 | 0.7.[1-5] | 1.0.x | r24355
Attachments
airport-upgrade-r11927.patch
(8.73 KiB) Downloaded 1192 times
Last edited by cirdan on 27 Jun 2012 18:22, edited 13 times in total.

User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Patch: Upgrade airports

Post by Bilbo » 20 Jan 2008 17:01

Good idea for a patch
cirdan wrote: - Atomicity: the town no longer has a chance to build roads or buildings between removal and rebuilding of an airport (very annoying).
Or even worse - your competitor in multiplayer or singleplayer (AI) can interfere with construction

Also, I have noted one thing regarding the coding style:

Code: Select all

/* Checks if an airport can be removed (no aircraft on it or landing) */
/* Returns cost on success, else an error */
static CommandCost CanRemoveAirport(Station *st, uint32 flags)
When you use comment as documentation comment for the function, start it with two "*" signs - this mean that it is comment for doxygen. Also, you can use special doxygen tags in the comment, like @param or @return to comment on function parameter or return value. So that piece of code should look rather somewhat like this:

Code: Select all

/** Checks if an airport can be removed (no aircraft on it or landing)
  * @param st Station to check
  * @param flags ... the flags are explained here ....
  * @return the cost in case of success, or an error code if it failed.
  */
static CommandCost CanRemoveAirport(Station *st, uint32 flags)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 22 Jan 2008 21:55

Bilbo wrote:Good idea for a patch
cirdan wrote: - Atomicity: the town no longer has a chance to build roads or buildings between removal and rebuilding of an airport (very annoying).
Or even worse - your competitor in multiplayer or singleplayer (AI) can interfere with construction
I don't usually play multiplayer, let alone with the AI, so I hadn't thought of that.
Bilbo wrote:Also, I have noted one thing regarding the coding style:

Code: Select all

/* Checks if an airport can be removed (no aircraft on it or landing) */
/* Returns cost on success, else an error */
static CommandCost CanRemoveAirport(Station *st, uint32 flags)
My plan was to ignore documentation until I got a dev's attention, and hope no one would notice... :-)

Seriously, thanks for the suggestion. The attached version has the comment ammended.
Attachments
airport-upgrade-r11947.patch
(8.82 KiB) Downloaded 341 times


User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 03 Apr 2008 18:38

Updated against 0.6.0.
Attachments
airport-upgrade-0.6.0.patch
(9.42 KiB) Downloaded 431 times

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9271
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Patch: Upgrade airports

Post by planetmaker » 24 May 2008 22:31

Okay, I'd like to drop a line :). Any chance for current trunk?

It might be a nice addition to wwottdgd. Close airports is an essential and this might nicely complement it; closing works with the changes I made and posted in the relevant thread :), but this not so far :(

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 25 May 2008 14:44

Happy to oblige. :-)

Note that the airport code has undergone some serious changes lately (to allow for noise-dependent maximum number of airports), so this patch may not be as stable as the last one. Please do report any bugs found.
Attachments
airport-upgrade-v6-r13232.patch
(10.3 KiB) Downloaded 270 times

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 03 Jun 2008 20:13

Patches against 0.6.1 and r13374.
Attachments
airport-upgrade-v6-0.6.1.patch
(9.27 KiB) Downloaded 341 times
airport-upgrade-v6-r13374.patch
(10.26 KiB) Downloaded 301 times

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 06 Jan 2009 21:04

Rebased against r14876, to make up for recent changes in the code (and over 7 months without an update).
Attachments
airport-upgrade-v6-r14876.patch
(10.25 KiB) Downloaded 270 times

Moriarty
Tycoon
Tycoon
Posts: 1395
Joined: 12 Jun 2004 00:37
Location: United Kingdom of Great Britain and Northern Ireland
Contact:

Re: Patch: Upgrade airports

Post by Moriarty » 10 Jan 2009 01:32

Any reason this hasn't found its way into trunk? It's requested fairly often.

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: Upgrade airports

Post by Gremnon » 10 Jan 2009 14:10

Almost forgot to mention.
Patched this into a clean trunk followed by close airport... try to upgrade an airport to a larger one, and get the error 'Too close to an other airport'

Conditional Zenith
Chief Executive
Chief Executive
Posts: 697
Joined: 10 Jun 2003 00:19
Location: Australia

Re: Patch: Upgrade airports

Post by Conditional Zenith » 10 Jan 2009 15:25

The obvious questions are:
1) Does this happen if you don't patch with close airport.
2) Is there actually another airport that's too close?

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: Upgrade airports

Post by Gremnon » 10 Jan 2009 15:35

1: Yes
2: No

I started a new game, placed small airport, attempt to upgrade, 'Too close to another airport'

Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4718
Joined: 09 Sep 2007 05:03
Location: home

Re: Patch: Upgrade airports

Post by Alberth » 10 Jan 2009 18:21

You didn't answer question 1:
Conditional Zenith wrote:1) Does this happen if you don't patch with close airport.
In other words, does the problem exist in trunk or in the patch?

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: Upgrade airports

Post by Gremnon » 10 Jan 2009 18:26

Actually, I did:
Gremnon wrote:1: Yes
A clean build, patched with upgrade airports and nothing else, still fails to allow upgrading airports.
Exactly as I said in the previous post.

Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Patch: Upgrade airports

Post by Roujin » 10 Jan 2009 19:26

Did you patch r14876, or something newer? After reading your post I was thinking that it could be due to the changes done while incorporating distant-join stations into trunk. But that was after r14876. That was r14915 to r14919 to be precise. So.. what revision did you use?
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: Upgrade airports

Post by Gremnon » 10 Jan 2009 19:35

I also thought something might have upset it slightly with distant join, so I tried the revision before it, and r14938... both of which refused to allow upgrading.

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 10 Jan 2009 20:00

Moriarty wrote:Any reason this hasn't found its way into trunk? It's requested fairly often.
No idea. The patch was first submitted to flyspray more than a year ago, and I have been posting updates there every now and then. Last time I did I also asked the devs what their opinion was about the patch, but I'm yet to receive an answer.
Gremnon wrote:Patched this into a clean trunk followed by close airport... try to upgrade an airport to a larger one, and get the error 'Too close to an other airport'
Gremnon wrote:A clean build, patched with upgrade airports and nothing else, still fails to allow upgrading airports.
Did the patch apply cleanly?

Trunk is currently undergoing heavy changes on a regular basis, making it difficult to keep patches up to date. The recent distant-join changes have made my last patch unusable. Could you please check if the problems persist with the new version of the patch I'm attaching?
Attachments
airport-upgrade-v6-r14977.patch
(10.35 KiB) Downloaded 256 times

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Patch: Upgrade airports

Post by Gremnon » 10 Jan 2009 20:11

No, the patch didn't apply perfect, there were a few failures on each which I hand fixed... which might have been the cause in the first place, but I'm not certain.

User avatar
cirdan
Director
Director
Posts: 539
Joined: 07 Apr 2007 18:08

Re: Patch: Upgrade airports

Post by cirdan » 10 Jan 2009 20:54

Yes, that could have been the cause. The changes introduced with the distant-join thing were small (in the relevant part of the code), but enough to interfere subtly with this patch.

By the way, does the new patch work for you?

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests