45° rotated rectangle clearing / leveling 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
mamuf
Engineer
Engineer
Posts: 33
Joined: 30 Mar 2007 21:31
Location: Prague, CZ

Re: 45° rotated rectangle clearing / leveling patch

Post by mamuf »

Bilbo wrote:As I looked in the patch - since it modifies the network protocol for leveling and clearing area by adding flag for dialognal clear ... no. Unfortunately, it is not network compatible.
Pity. But I can live with that :wink:
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Re: 45° rotated rectangle clearing / leveling patch

Post by CobraA1 »

What's the return value of || or && ? Obviously boolean, since they're logic operators, so no need for the if.
Well, yes, it's obvious to you and me - we've both been programming for quite some time.

I remember, though, that when I first started programming, that logical equations could confuse me.

I usually try not to do computations in the return statement - I guess it's mostly a matter of style.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

I´ll be at my home computer in a few days. When I do I will round up the function stuff.
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
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

I am currently working on the function, but I have some questions about a bit of code.

Code: Select all

	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
		curh = TileHeight(tile2);
		while (curh != h) {
			ret = DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
			if (CmdFailed(ret)) break;

			if (flags & DC_EXEC) {
				money.AddCost(-ret.GetCost());
				if (money.GetCost() < 0) {
					_additional_cash_required = ret.GetCost();
					return cost;
				}
				DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
			}

			cost.AddCost(ret);
			curh += (curh > h) ? -1 : 1;
		}
	} END_TILE_LOOP(tile2, size_x, size_y, tile)
Is it ok to replace the above code with:

Code: Select all

		for (int x = sx; x <= ex; ++x) {
			for (int y = sy; y <= ey; ++y) {
			
				curh = TileHeight(TileXY(x, y));
				while (curh != h) {
					ret = DoCommand(TileXY(x, y), 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
					if (CmdFailed(ret)) {
						money.AddCost(-ret.GetCost());
						curh += (curh > h) ? -1 : 1;
						continue;
					}
	
					/* To be able to determine how much the operation will cost, add the cost to cost. */
					cost.AddCost(ret);
	
					if (flags & DC_EXEC) {
						money.AddCost(-ret.GetCost());
						if (money.GetCost() < 0) {
							_additional_cash_required = ret.GetCost();
	
							/* Remove cost for not executed DoCommand from cost. So it is not billed anyway.*/
							cost.AddCost(-ret.GetCost());
							return cost;
						}
						DoCommand(TileXY(x, y), 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
					}
	
					curh += (curh > h) ? -1 : 1;
				}
			}
		}
The change in code will make the innards more compatible with the code from landscape.cpp. It will allow me to use the same innards for diagonal demolishing and leveling. Which in turn will make it easier to turn the repeated statement into a function.
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
Snuk the Great
Engineer
Engineer
Posts: 63
Joined: 26 Aug 2005 15:12

Re: 45° rotated rectangle clearing / leveling patch

Post by Snuk the Great »

Is this thing still being worked on?
Snuk the Great
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

I'm looking into it from time to time, but as I am a student. I do not have much time to spend on patches.

Also I was thinking on how to do the function stuff. If the patch doesn't apply anymore, please let me know. I will be happy to up it to the latest nightly.
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
chrissicom
Route Supervisor
Route Supervisor
Posts: 415
Joined: 07 Oct 2004 10:05

Re: 45° rotated rectangle clearing / leveling patch

Post by chrissicom »

I haven't looked at the original patch for quite a while, but the code used in ChrisIN from this patch has been updated quite a few times and works fine. The code isn't super nice but it works and has no known bugs and it's also network compatible, don't know why someone above said this patch isn't network compatible. So if you look at the .diff for this patch it won't be too much work to extract the required changes from the ChrisIN .diff.
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

Thanks Chrissicom, I will try to rediff this file later tonight or look at the changes you have made.
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
ZenneZ
Engineer
Engineer
Posts: 1
Joined: 22 Oct 2007 15:41

Re: 45° rotated rectangle clearing / leveling patch

Post by ZenneZ »

Hello,

Can i use this patch with 0.5.3? And use it so easy like Build Templates (Copy&Paste) (r11248 + 0.5.3) ?
User avatar
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

No you cannot, although it is in the ChrisIn. Which is probably the best thing at the moment if you wish to play with this feature. Please look in this forum for a topic about the CrisIN

As soon as I have enough time to continue work on this patch. I will finish it up.
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
aepurniet
Engineer
Engineer
Posts: 9
Joined: 13 Nov 2007 14:42

Re: 45° rotated rectangle clearing / leveling patch

Post by aepurniet »

is this abandoned? its my favorite feature thats not in the trunk yet.
Connum
Engineer
Engineer
Posts: 127
Joined: 25 Dec 2006 17:05

Re: 45° rotated rectangle clearing / leveling patch

Post by Connum »

I would like to see this in trunk as well... I hope somebody will take this feature up again.
English is not my native language, so please excuse me if I sometimes might appear a bit harsh or if I make a spelling or grammar mistake!
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: 45° rotated rectangle clearing / leveling patch

Post by Roujin »

I've made a patch for terraforming that does something else. When holding CTRL, you can "draw" any area you want for tools like raise, lower, level, dynamite, place rivers and place stones (last two for scedit).
Maybe you want to give it a try? It's also included in Gonozal's patch pack.
* @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
Connum
Engineer
Engineer
Posts: 127
Joined: 25 Dec 2006 17:05

Re: 45° rotated rectangle clearing / leveling patch

Post by Connum »

sure I'll give it a try, thanks!
English is not my native language, so please excuse me if I sometimes might appear a bit harsh or if I make a spelling or grammar mistake!
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by belugas »

For the record, I am still interested in that patch, but it will not be in 0.6.
Let's wait for it to be released (no.. you wait, we work in releasing it) and than we'll see if it can be put in trunk or not.
The idea is wonderful, we all agree on 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
NukeBuster
Traffic Manager
Traffic Manager
Posts: 222
Joined: 04 Jan 2006 18:16
Location: Alphen aan den Rijn, The Netherlands
Contact:

Re: 45° rotated rectangle clearing / leveling patch

Post by NukeBuster »

The latest problem was, that at the moment the CTRL key is already used for something else. There is a discussion going on on how to solve it.

If that could be solved, I would be willing to finish up the remaining stuff. But there would need to be a clean solution. (I could use another key, but there was much upheavel on what key to use.(I'd still suggest Z))

Regards.
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
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: 45° rotated rectangle clearing / leveling patch

Post by Bilbo »

The CTRL was used in the another terrain modificaztion patch for "drawing" the terrain, so in that mode you have ordinary levelling and with Ctrl drawing, in the new "diagonal" mode you could have still ordinary levelling and with ctrl 45 degrees rotated levelling. Since IMHO moere people woudl use then 45 rotated levelling, perhaps it can be even the 'default' with old keyboard shortcut and the freedraw mode will get 'Z' as shortcut (or let people configure it in patches)
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)
PhilSophus
Chairman
Chairman
Posts: 776
Joined: 20 Jan 2007 12:08
Location: Germany

Re: 45° rotated rectangle clearing / leveling patch

Post by PhilSophus »

Bilbo wrote:Since IMHO more people woudl use then 45 rotated levelling, perhaps it can be even the 'default' with old keyboard shortcut and the freedraw mode will get 'Z' as shortcut (or let people configure it in patches)
I agree with that. I have never missed that freedraw mode (I don't want to say it isn't useful for others, especially in the scenario editor which I have never really used), but I miss diagonal leveling almost every time I build diagonal rails.
"The bigger the island of our knowledge, the longer the shore of our ignorance" - John A. Wheeler, Physicist, 1911-2008
User avatar
kyosuke1989
Transport Coordinator
Transport Coordinator
Posts: 273
Joined: 24 Mar 2008 13:04
Location: Finland

Re: 45° rotated rectangle clearing / leveling patch

Post by kyosuke1989 »

When this patch was integrated in trunk? :)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: 45° rotated rectangle clearing / leveling patch

Post by planetmaker »

kyosuke1989 wrote:When this patch was integrated in trunk? :)
http://hg.openttd.org/openttd/trunk.hg/log?rev=diagonal leads to 13 December 2010
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 9 guests