resurrection of diagonal level and clear 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

User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

resurrection of diagonal level and clear patch

Post by fonso »

Below you can find the patches diagonal levelling. The "tileiter" patch only implements the tile iterators which can be reused for other purposes. It also rewrites the normal levelling and clearing methods to use the orthogonal iterator. The "diaglvl" patch implements the actual levelling and clearing on top of the diagonal iterator. For convenience I also provide an all-in-one patch implementing both. Thanks for your feedback.

You can also pull them from my git repository at git://github.com/fonsinchen/openttd-cargodist.git
Each patch has its own branch. The branches are called "tileiter" and "diaglvl".
An up-to-date all-in-one patch at at http://github.com/fonsinchen/openttd-ca ... aglvl.diff
It applies to the trunk version given in http://github.com/fonsinchen/openttd-ca ... ERSION.txt
Last edited by fonso on 10 Jun 2010 21:18, edited 5 times in total.
The guy on the picture is not me, it's Alonso.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: resurrection of diagonal level and clear patch

Post by Zuu »

I'll try.

One argument can be that there are people that don't know of all fancy CTRL-options available in OpenTTD. If you follow the development of OpenTTD you'll learn the new CTRL behaviors one after another but if you are new to OpenTTD it can take long time to find all various nice features that are "hidden" on the CTRL-key.

I don't know if anyone have vented any such comments in the previous thread but sometimes people do vent such things on patches. But add a note that CTRL toggles diagonal operation in the tooltip of the affected buttons in the landscape toolbar and it should be enough I think. (Let's leave out the discussion about if tooltips should be shown automatically or not)


EDIT: I did my homework and read through two old thread on the subject and only found one argument. That there is another patch using CTRL but it was argued that diagonal leveling is more useful and therefor should use CTRL. http://www.tt-forums.net/viewtopic.php?p=668831#p668831
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

Ah, I see, thanks. Somehow I didn't realize they meant the drag&draw patch. Why does the drag&draw patch need the CTRL key anyway? Would anyone notice if drag&draw became the default behaviour for raise and lower? I mean, it's pretty much what you'd expect when keeping the mouse button pressed and moving the cursor around, isn't it? Like that only explicit levelling would actually do levelling. At the same time I wouldn't have to care about diagonal raise and lower. And as an additional benefit we'd get rid of the problem that raise can lower terrain in certain situations (and the other way round). Perhaps we should have a poll: Who is actually using area raise and lower instead of raising or lowering one tile and then using level from there?

We still need a solution for drag&draw levelling then ... any ideas? Do we need it?
The guy on the picture is not me, it's Alonso.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: resurrection of diagonal level and clear patch

Post by Roujin »

Well, I've been trying my luck with the devs about my drag&draw terraform before, but they didn't seem too interested.. even when I tuned it down to a scedit-only version that doesn't use CTRL, after one of them proposed that to me (they seem reluctant to add stuff that uses CTRL), I got no more feedback after that.

Sorry for having not updated it for a while, been busy with university lately...

edit: okay, I have to withdraw the part about no answer.. SmatZ wrote an answer in my flyspray task 2 days ago. ;)
* @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
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

A somewhat simplified version of the same patch. Does the same thing, but eliminates the if-else ugliness. The issue with consistency and CTRL usage isn't resolved due to lack of better ideas. Perhaps I should take a look at that Flyspray thing, too ...
Attachments
diagonal_demolish_and_leveling_r13670.diff
(17.32 KiB) Downloaded 348 times
The guy on the picture is not me, it's Alonso.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: resurrection of diagonal level and clear patch

Post by planetmaker »

fonso wrote:Who is actually using area raise and lower instead of raising or lowering one tile and then using level from there?
I do :). But that's indeed something I could live without, if I trade diagonal terraform tools for that :)
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

New version with some cosmetic changes.
Attachments
diagonal_demolish_and_leveling_r13890.diff
(17.35 KiB) Downloaded 411 times
The guy on the picture is not me, it's Alonso.
User avatar
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: resurrection of diagonal level and clear patch

Post by Wolf01 »

planetmaker wrote:
fonso wrote:Who is actually using area raise and lower instead of raising or lowering one tile and then using level from there?
I do :). But that's indeed something I could live without, if I trade diagonal terraform tools for that :)
I would trade both the diagonal etc tool and the raise/lower area tool for the "paint" (drag&draw) tool
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

renamed some variables as requested. Fixed some indentation problems.
Attachments
diaglvl_r14004.diff
(18.14 KiB) Downloaded 288 times
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

new version with iterators instead of duplicated code, flags for leveling modes and cosmetics.
Attachments
diaglvl_r14012.diff
(17.97 KiB) Downloaded 269 times
The guy on the picture is not me, it's Alonso.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: resurrection of diagonal level and clear patch

Post by Yexo »

Nice patch, I hope this'll make it to trunk someday.

Some small comments about the style:

Code: Select all

+	if (p2 & LEVEL_RAISE)
+		h++;
+	else if (p2 & LEVEL_LOWER)
+		h--;
You should use brackets if you put h++ on a different, and always for else statements. So it'll become.

Code: Select all

+	if (p2 & LEVEL_RAISE) {
+		h++;
+	} else if (p2 & LEVEL_LOWER) {
+		h--;
+	}
You do this some more times in your patch.

Code: Select all

DoCommandP(end_tile, start_tile, _ctrl_pressed, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
Looks like you forgot to change _ctrl_pressed to _ctrl_pressed ? LEVEL_DIAG : 0 on this line, and for CmdClearArea in general.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: resurrection of diagonal level and clear patch

Post by belugas »

Sharp eye Yexo :)
Let say that this patch has never been closer to trunk inclusion :D
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
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

Thanks Yexo.

The brackets thing was unknown to me. I know I should memorize the coding style better :(.
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

Next version with all if-else bracketified, where needed and CmdClearArea also uses LevelMode (although I could argue about that ...).
Attachments
diaglvl_r14018.diff
(18.05 KiB) Downloaded 350 times
The guy on the picture is not me, it's Alonso.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Re: resurrection of diagonal level and clear patch

Post by peter1138 »

I don't think LevelMode should be declared in command_type.h.

Another minor code-style thing; can you place the { after a function on a new line. There are still some missing braces around some if () statements. :)
He's like, some kind of OpenTTD developer.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

new version with (hopefully) all the brackets correct now, LevelMode divided into LevelMode and Orientation, iterating with *Iterator::end.

Edit: forgot the brackets at function start; corrected now.
Attachments
diaglvl_r14020.diff
(19.25 KiB) Downloaded 311 times
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

To sum it up:

- blathijs likes it as it is now
- peter1138 finds the *Iterator::end confusing because it contains "random values"
- hylje considers the whole idea of C++ iterators braindead
- others are silent

I don't care. I'll happily make a java style iterator of it, or change it back so that you have to dereference it to get the end condition or insert a special "end" flag somewhere or even make a common base class which provides an empty "end" member or whatever. But I'm at a loss now. Please comment.
The guy on the picture is not me, it's Alonso.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

ok, now I have two alternative versions. One with java-style iterators which is very concise and clean and one with more elaborate c++-style iterators which provides an extra class InvalidIterator, so that I don't need to fill the invalid iterator with random stuff.
Attachments
diaglvl_invit_r14026.diff
(20.08 KiB) Downloaded 190 times
diaglvl_java_r14026.diff
(17.71 KiB) Downloaded 174 times
The guy on the picture is not me, it's Alonso.
User avatar
RSpeed tycoonfreak
Transport Coordinator
Transport Coordinator
Posts: 349
Joined: 02 Feb 2006 13:17
Location: Azewijn The netherlands
Contact:

Re: resurrection of diagonal level and clear patch

Post by RSpeed tycoonfreak »

I like this idea, can i see a screenshot please?
Visit The Fake Airport Website
Image
Hobbys: being 18 years old, soccer, go karting, and transport tycoon.
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: resurrection of diagonal level and clear patch

Post by fonso »

RSpeed tycoonfreak wrote:I like this idea, can i see a screenshot please?
Sure. Here are some. Forgive the strange screenshot windows ... I'll have to investigate that.
Attachments
level_highlight.png
Highlight area for leveling
(57.26 KiB) Downloaded 520 times
level_action.png
and do the leveling
(69.21 KiB) Downloaded 485 times
demolish_action.png
*bang* (no highlight for demolish shown because of 3 file limit)
(56.75 KiB) Downloaded 469 times
The guy on the picture is not me, it's Alonso.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 12 guests