Diagonal demolish / level land patch

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

l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Diagonal demolish / level land patch

Post by l_Blue_l »

Below is an update of an old patch found here that was coded by Diadem.

What this patch does is it lets you demolish or level land diagonally when you use the control key.

At this stage it has only been updated to the current revision. If there are any bugs, coding advice or extra functionality related to this patch and it has merit i will more then likely be happy to make the related changes.
Attachments
Diagonal_Clearing_v1.0_r9538.patch
(18.37 KiB) Downloaded 307 times
1.PNG
1.PNG (59.84 KiB) Viewed 11216 times
2.PNG
2.PNG (62.91 KiB) Viewed 11213 times
Last edited by l_Blue_l on 03 Apr 2007 08:33, edited 1 time in total.
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

more images
Attachments
4.PNG
4.PNG (53.65 KiB) Viewed 11213 times
3.PNG
3.PNG (57.01 KiB) Viewed 11215 times
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

Yeah! Awesome! I forgot about this patch, I read it in the other older thread. I hope this one to get merged within trunk! :D

I could use this extremely well! :D
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post by Maedhros »

Some coding points:
  • Don't use multi-line macros. In fact, don't use macros at all if you can avoid it.
  • This is possibly outside the scope of the patch, but I think it would be better to send the start and finish co-ordinates to the DoCommand, rather than executing it for every tile that gets levelled.
  • You can replace this (notice the corrected coding style too ;))

    Code: Select all

    if (_ctrl_pressed) {
       DoCommand(..., 1, ...);
    } else {
       DoCommand(..., 0, ...);
    }
    with this:

    Code: Select all

    DoCommand(..., _ctrl_pressed ? 1 : 0, ...);
  • Don't use all upper-case for function names; use e.g. IsInsideRotatedRectangle instead.
  • Take care with spacing and brackets (the style we use is described here: http://wiki.openttd.org/index.php/Coding_style).
No-one's more important than the earthworm.
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Post by NukeBuster »

This is a really great addition, i was already waiting for someone to bring it up to the latest nightly. :D

It really saves A LOT of time while building diagonal track :)
NukeBuster

Transport Empire: The Transport Empire Linux effort
Join the Transport Empire IRC channel: [url]irc://irc.oftc.net/transportempire[/url] !

OpenTTD patch(es): Password at join
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

Code-style :
With C++, this is not needed change

Code: Select all

-struct TileHighlightData {
+typedef struct TileHighlightData {
Comments that are on one line (or spawn on more than more line) will be like this

Code: Select all

/* Need to Mark odd and even tiles (compare with checkerboard: black and white squares) */
and not

Code: Select all

// Need to Mark odd and even tiles (compare with checkerboard: black and white squares)
Functions/macros definitions should use the same type of comment

Code: Select all

+// Check to see if x,y lies within the selected 45° rotated rectangle.
+// Called by DrawTileSelection() immidiately below.
+bool IS_INSIDE_RR(int x, int y)
is bad. The following is the desired way

Code: Select all

+/**
+ * Check to see if x,y lies within the selected 45° rotated rectangle.
+ * Called by DrawTileSelection() immidiately below.
+ * @param x blablabla
+ * @param y blablabla
+ * @return another blablabla
+ */
+bool IS_INSIDE_RR(int x, int y)
Maybe i'm wrong, but i think DO_CLEAR_AREA and others alike could be made a function by itself/themselves.

As for the patch itself, i still like it ;)
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

I agree. This must make it in the trunk as soon as possible.
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

athanasios wrote:I agree. This must make it in the trunk as soon as possible.
No, not as soon as possible.:roll:
It's not a question of life and death ;)

When it it will be ready, and when the other devs agree on incorporation
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I would note that this feature was first diffed against rev 2335. Two three three five. No, that's not a mistake; Diadem was not the first to implement this.

That's a long time for this to get in, if The Powers actually were interested in it.
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
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

DaleStan wrote:Two three three five.
I think it has in the mean time gotten old and wrong (code-wise).

Some things are just laying around never to be impelemented and later when someone digs up an old feature it's 'too old to make it'. I say when something is good to get into the trunk, and demand for that specific feature is high, get it in immidiatly before it gets tagged as 'old'.

Or developers had a different idea about that feature (it was not good (code wise) to start with or for another reason and my rant here goes down with the fishies, but I know there are more people here with the same idea about 'old but high demanding' features that never made it.

Can someone clear it up a bit to take away all the clouds? :)
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

DaleStan wrote:That's a long time for this to get in, if The Powers actually were interested in it.
Got anything positive to add?
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
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post by Maedhros »

Mr. X wrote:Some things are just laying around never to be impelemented and later when someone digs up an old feature it's 'too old to make it'. I say when something is good to get into the trunk, and demand for that specific feature is high, get it in immidiatly before it gets tagged as 'old'.
It becomes too old to make it because of all the changes in trunk. If it's in trunk it's the main developers maintaining it, if not it's the patch author, but someone has to do it either way. Just being in trunk doesn't mean that the code automatically becomes current, just that the maintenance becomes invisible to everyone who doesn't scrutinise all the trunk commits. That's why we have strict rules about the coding style, and why not everything gets committed to trunk.
No-one's more important than the earthworm.
l_Blue_l
Transport Coordinator
Transport Coordinator
Posts: 285
Joined: 29 Mar 2006 22:42
Contact:

Post by l_Blue_l »

Thank you Maedhros and belugas for the coding advice. I expect i will be able to fix up the patch over the weekend so early next week there will be an updated version of this patch.

On a side note could all discussion that does not relate to this patch please discontinue.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

l_Blue_l wrote:On a side note could all discussion that does not relate to this patch please discontinue.
Wise man :lol:
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Mikeyspike
Engineer
Engineer
Posts: 21
Joined: 11 Feb 2007 17:18

Post by Mikeyspike »

hey guys, havn't posted in a wile, but heres a realy noobish question, how do i install these patches?

thanks :)
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

Maedhros wrote:
Mr. X wrote:Some things are just laying around never to be impelemented and later when someone digs up an old feature it's 'too old to make it'. I say when something is good to get into the trunk, and demand for that specific feature is high, get it in immidiatly before it gets tagged as 'old'.
It becomes too old to make it because of all the changes in trunk. If it's in trunk it's the main developers maintaining it, if not it's the patch author, but someone has to do it either way. Just being in trunk doesn't mean that the code automatically becomes current, just that the maintenance becomes invisible to everyone who doesn't scrutinise all the trunk commits. That's why we have strict rules about the coding style, and why not everything gets committed to trunk.
Okay, that seems understandable, thanks for shedding some light on it. :)
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

Mikeyspike wrote:hey guys, havn't posted in a wile, but heres a realy noobish question, how do i install these patches?

thanks :)
Search!

Or read this : http://www.tt-forums.net/viewtopic.php?t=21678

:roll:
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Mikeyspike
Engineer
Engineer
Posts: 21
Joined: 11 Feb 2007 17:18

Post by Mikeyspike »

sorry :oops: but i don't understand any of that, where do i add the code? sorry, im realy noobish :oops: ill search but i stilll wnat to ask here
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

richk67 wrote:
DaleStan wrote:That's a long time for this to get in, if The Powers actually were interested in it.
Got anything positive to add?
I guess I'm a little irritated that basically no one was interested it this back then, and now, all of a sudden, it's the best thing since sliced bread.
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
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Post by belugas »

Belugas wrote:As for the patch itself, i still like it Wink
This is what i wrote
Dalestan wrote:all of a sudden, it's the best thing since sliced bread.
This is how you interpret it. Maybe you exagerate a bit my enthusiasm? Or maybe it was another post from somebody else that blew the fuse? DOn't know which one...
Dalestan wrote:basically no one was interested it this back then,
I was aware of the patch "back then" and found it quite appealing, but was not in a postion to do anything about it.
Now that i can "take it into trunk", things are a bit different.
Always put things in context, please
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
Locked

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 25 guests