Page 1 of 2
Diagonal demolish / level land patch
Posted: 03 Apr 2007 08:31
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.
Posted: 03 Apr 2007 08:32
by l_Blue_l
more images
Posted: 03 Apr 2007 08:41
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!
I could use this extremely well!

Posted: 03 Apr 2007 09:07
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).
Posted: 03 Apr 2007 10:36
by NukeBuster
This is a really great addition, i was already waiting for someone to bring it up to the latest nightly.
It really saves A LOT of time while building diagonal track

Posted: 03 Apr 2007 17:12
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

Posted: 03 Apr 2007 23:06
by athanasios
I agree. This must make it in the trunk as soon as possible.
Posted: 04 Apr 2007 01:20
by belugas
athanasios wrote:I agree. This must make it in the trunk as soon as possible.
No, not as soon as possible.

It's not a question of life and death
When it it will be ready, and when the other devs agree on incorporation
Posted: 04 Apr 2007 03:04
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.
Posted: 04 Apr 2007 07:58
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?

Posted: 04 Apr 2007 09:17
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?
Posted: 04 Apr 2007 09:47
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.
Posted: 04 Apr 2007 10:32
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.
Posted: 04 Apr 2007 10:40
by belugas
l_Blue_l wrote:On a side note could all discussion that does not relate to this patch please discontinue.
Wise man

Posted: 04 Apr 2007 11:35
by Mikeyspike
hey guys, havn't posted in a wile, but heres a realy noobish question, how do i install these patches?
thanks

Posted: 04 Apr 2007 12:20
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.

Posted: 04 Apr 2007 13:20
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

Posted: 04 Apr 2007 16:07
by Mikeyspike
sorry

but i don't understand any of that, where do i add the code? sorry, im realy noobish

ill search but i stilll wnat to ask here
Posted: 04 Apr 2007 20:05
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.
Posted: 04 Apr 2007 23:18
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