Page 1 of 5

Patch: Upgrade airports

Posted: 20 Jan 2008 12:20
by cirdan
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

Re: Patch: Upgrade airports

Posted: 20 Jan 2008 17:01
by Bilbo
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)

Re: Patch: Upgrade airports

Posted: 22 Jan 2008 21:55
by cirdan
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.

Re: Patch: Upgrade airports

Posted: 25 Jan 2008 23:19
by SirkoZ
Nice patch, cirdan, keep up the good work. ;-)

Re: Patch: Upgrade airports

Posted: 03 Apr 2008 18:38
by cirdan
Updated against 0.6.0.

Re: Patch: Upgrade airports

Posted: 24 May 2008 22:31
by planetmaker
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 :(

Re: Patch: Upgrade airports

Posted: 25 May 2008 14:44
by cirdan
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.

Re: Patch: Upgrade airports

Posted: 03 Jun 2008 20:13
by cirdan
Patches against 0.6.1 and r13374.

Re: Patch: Upgrade airports

Posted: 06 Jan 2009 21:04
by cirdan
Rebased against r14876, to make up for recent changes in the code (and over 7 months without an update).

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 01:32
by Moriarty
Any reason this hasn't found its way into trunk? It's requested fairly often.

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 14:10
by Gremnon
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'

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 15:25
by Conditional Zenith
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?

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 15:35
by Gremnon
1: Yes
2: No

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

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 18:21
by Alberth
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?

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 18:26
by Gremnon
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.

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 19:26
by Roujin
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?

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 19:35
by Gremnon
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.

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 20:00
by cirdan
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?

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 20:11
by Gremnon
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.

Re: Patch: Upgrade airports

Posted: 10 Jan 2009 20:54
by cirdan
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?