Chunnel V23 r27765

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
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Chunnel V23 r27765

Post by HackaLittleBit »

Chunnel patch.

Wat it does.
Enabeling building tunnels crossing water.

Features.
Only on tile level 0 it is possible to use.
Tunnel building tool switches automatically to chunnelmode when water encountered.
Any kind of coast tile can be used.
Tunnels over water can cross each other.

Limitations: Oil rigs can not be constructed on top of chunnel, nor can the be passed by chunnel.

Happy Tunneling.
Attachments
Chunnel.png
Chunnel.png (98.23 KiB) Viewed 21614 times
chunnel_trunk_27765_v23.zip
(28.33 KiB) Downloaded 556 times
Last edited by HackaLittleBit on 06 Mar 2017 18:53, edited 29 times in total.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

not bad, not bad at all! :)

Nice idea to use this corner case for undersea tunnels. It doesn't make sense to build a tunnel that ends right in front of water anyways, so I don't think anyone will miss that situation...

Oh and it was good practice to seperate undersea tunnels from the "tunnel-like-you-want"-tunnels you had in your last patch. :)
But there's still two seperate features in this patch that could be seperated - "build undersea tunnels" and "display exit in viewport when holding ctrl while building a tunnel".

Two seperate patches for two features will each have a higher chance on trunk inclusion than two features in one patch. ;)

edit: testing your patch...
* @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
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

So... after some testing I've got some things to mention.

Firstly, the viewport popup should really not happen on only pressing Ctrl. Ctrl+Click: okay. Only Ctrl: no-no. For example, I got extremely annoyed by it when I tried to take a screenshot using Ctrl+S, while selecting the tile I wanted some tunnel built (see screenshot below), so one can see the selection.
(and as I said before, it's better to put those two features in two different patches)

Secondly, there is some inconsistency in when you can build a tunnel under water, and when not.
Compare screenshot #1 and screenshot #2 for a situation where trying the tunnel from one end will allow the undersea tunnel, but from the other end will result in a tunnel ending at the water edge. It seems that your patch doesn't handle diagonal water edges very well...

Also see screenshot #3 for an overview where the desired undersea tunnel can be built and where not, in my setup.
The green dots are where I could build the desired tunnel, the yellow and red dots are where it did not work. The yellow dot is probably due to a slightly different problem (the water being only 1/2 tile wide there) than the red dots (diagonal water edge at the nearer side), so I colored it different.


---
Oh, and found another problem, that may be a conceptual problem:
It is possible to raise any tile in the stretch where the tunnel is going undersea, but not to lower it anymore.
This also enables you to make impossible constructions like this (screenshot #4 in next post).

... and finally, it enables you to make crossing tunnels without enabling the crossing tunnels cheat. (screenshot #5 in next post)

I am not sure how to address these last issues...
Attachments
chunnel #1.png
chunnel #1.png (64.53 KiB) Viewed 42459 times
chunnel #2.png
chunnel #2.png (63.67 KiB) Viewed 42470 times
chunnel #3.png
chunnel #3.png (61.33 KiB) Viewed 42470 times
* @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
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

screenshots #4 and #5
Attachments
chunnel #4.png
chunnel #4.png (57.33 KiB) Viewed 42472 times
chunnel #5.png
chunnel #5.png (64.14 KiB) Viewed 42448 times
* @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
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Thanks Roujin

Am checking your post now.
will hear of me later.

Split patch in two see above

regards.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Ok the issue of Ctrl
Changed it into V + Ctrl
V is standard viewport.
when viewport open Ctrl fixes on end tile.
Made this feature to avoid loosing crazy amounts of money while building wrong tunnel.

Will come back to you regarding other issues.

HackaLittleBit.
Attachments
viewport _V_plus_Ctrl.patch
(2.37 KiB) Downloaded 608 times
Eddi
Tycoon
Tycoon
Posts: 8254
Joined: 17 Jan 2007 00:14

Re: Chunnel v1 r15422

Post by Eddi »

Ctrl with other actions is used for too many "magic" functions in the game, i think it is a very bad idea to make it do something on its own.

at best, you could use Ctrl+V to open a viewport at the "target" place of the tunnel.
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Secondly, there is some inconsistency in when you can build a tunnel under water, and when not.
Compare screenshot #1 and screenshot #2 for a situation where trying the tunnel from one end will allow the undersea tunnel, but from the other end will result in a tunnel ending at the water edge. It seems that your patch doesn't handle diagonal water edges very well...
Check this line in the code it says it all
if (IsWaterTile(end_tile + delta) && !IsWaterTile(start_tile - delta)) passing_water = true;
so shoreline is not considered a water tile.
I could make it more flexible the code but I think that it is in a way allready futuristic and if people want to make an tunnel under water they have to prepare the shore line.

This also enables you to make impossible constructions like this (screenshot #4 in next post).
Whats wrong there am I not allowed to make a tunnel under island?
About this raising and lowering land I'll come back to you.

Screenshot 5
Am not able to reproduce that situation.
Are you shure you switched off the tunnel_cheat?
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Ok about this diagonal building I fixed that.
see patch and foto

regards
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

Here's how I did the crossing tunnels in three steps:

(screenshot taken with the old version of your patch, but just tested the new one (v3) and it still works)
Attachments
chunnel bug #1.png
chunnel bug #1.png (47.63 KiB) Viewed 42269 times
chunnel bug #2.png
chunnel bug #2.png (54.27 KiB) Viewed 42271 times
chunnel bug #3.png
chunnel bug #3.png (49.69 KiB) Viewed 42252 times
* @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
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Thanks a lot Roujin

Know exactly where to look.

Code: Select all

bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
{
	TileIndexDiff delta = TileOffsByDiagDir(dir);
	uint height;

	do {
		tile -= delta;
		if (!IsValidTile(tile)) return false;
		height = GetTileZ(tile);
		if (IsTileType(tile, MP_WATER)) height += 1;  // Underwater tunnels
	} while (z < height);

	return
		z == height &&
		IsTunnelTile(tile) &&
		GetTunnelBridgeDirection(tile) == dir;
}
while (z < height); here it is!!
need to have a good look at this procedure will take some time

regards HackaLittleBit
User avatar
Thief^
Route Supervisor
Route Supervisor
Posts: 469
Joined: 10 Oct 2004 00:11

Re: Chunnel v1 r15422

Post by Thief^ »

Can I suggest that underwater tunnels be more expensive than normal tunnels?
Melt with the Shadows,
Embrace your destiny...
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Chunnel v1 r15422

Post by michael blunck »

Thief^ wrote:Can I suggest that underwater tunnels be more expensive than normal tunnels?
Not necissarily.

At least IRL, mined tunnels are the most expensive, regardless if subterraneous or underwater. OTOH, in flat waters, "floating assembly" of a tunnel is usually much cheaper than having to use sophisticated and expensive tunnel drilling machines in hard rock zones.

Nevertheless, it´d be an interesting feature to be able to set cost of tunnels differently from newgrfs.

regards
Michael
Image
User avatar
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Latest update of patch
Solved most of the problems encountered by Roujin.
Problems remaining:

Terra forming downward not allowed over tunnel upward allowed(Is that a problem?)

Now the cost of creating the tunnel through water is cheaper than through land.
I suggest to keep these costs the same. although don't know how to do that.

Regards
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Chunnel v1 r15422

Post by planetmaker »

hackalittlebit wrote:Terra forming downward not allowed over tunnel upward allowed(Is that a problem?)
It's not understandable, that you cannot restore the previous condition, should you have accidentially made sea into land. So, I think, it's something which needs taken care of.

An evil person could use this to totally sabotage your shipping routes without you having the possibility to undo it.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

hackalittlebit wrote:Latest update of patch[...]
nice, here's some more testing by mr. extreme-bug-finder ;)
Solved most of the problems encountered by Roujin.
very short tunnels can still bypass the no-crossing-tunnels limitation (see screenshot)
(the long tunnel again was an undersea tunnel, then filling up some land and building the very short tunnel; finally filling up the remains of the sea 8))
chunnel vst.png
chunnel vst.png (43.64 KiB) Viewed 41830 times
Terra forming downward not allowed over tunnel upward allowed(Is that a problem?)
[...]
I'd say it is, because it does not make sense: imagine there's a sea and you build a tunnel through it. You can then raise a piece of land where the tunnel is supposed to be. But then you cannot flatten it again? For what logical reason would that be?
Plus it destroys the image of a floating tunnel, that is used when building such an undersea tunnel.

The problem if you want to enable both raising and lowering is, then you have to enable lowering everywhere, that would mean tunnels being complete wormholes. No more "can't lower land here: tunnel in the way", crossing tunnels by default, heck why not introduce the arbitrary tunnels again then?
So the only way to go would be disallowing both raising and lowering. Luckily, there is also a logical explanation for it: we just say those undersea tunnels are of the "floating tunnel" kind. This of course explains why it's forbidden to raise a tile above the undersea part of the tunnel: the tunnel is floating in the water there, so it's in the way if you plan to raise the land there.
As a bonus, imo it would even give a logical explanation for the following discrepancy:

Forbidden: raise land in the middle of a sea tunnel
chunnel disc_1.png
chunnel disc_1.png (48.1 KiB) Viewed 41834 times
Allowed: destroying the tunnel, raising the land in the middle of the sea, building the tunnel again
chunnel disc_2.png
chunnel disc_2.png (49.31 KiB) Viewed 41831 times
The explanation for this would be (again using the idea of floating tunnels) that floating tunnels are used in the second picture from coast to coast, then a little peace of normal land tunnel, then again a floating sea tunnel from coast to coast. This cannot be archieved just by filling up some land when there is already a floating sea tunnel through the whole sea (image 1).


---
Uhm, are my ideas still understandable? :lol:
* @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
HackaLittleBit
Director
Director
Posts: 550
Joined: 10 Dec 2008 16:08
Location: tile 0x0000

Re: Chunnel v1 r15422

Post by HackaLittleBit »

Ok Here the reply to planetmaker
No more terra forming over undersee tunnels
Now going to have a look at your message Roujin
EDIT: Think it should not be possible anymore now.

regards
Last edited by HackaLittleBit on 09 Feb 2009 22:22, edited 1 time in total.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Chunnel v1 r15422

Post by Roujin »

hackalittlebit wrote:Ok Here the reply to planetmaker
No more terra forming over undersee tunnels
Now going to have a look at your message Roujin

regards
with that, you basically already did what I said in the second (larger!) part of my last post. nice!

so the only thing remaining is the bug with a very short tunnel being allowed where it shouldn't be.

edit: tested new version 5 and noticed two more small things
I hope you're still regarding this as valuable input, and I am not just annoying you :)

1) the error message when raising land over an undersea tunnel is a little wrong.. it's mentioning an excavation, while you're actually filling up land. I think you should just add a new string (something like "filling would damage undersea tunnel")

2) small discrepancy between two situations:

Allowed (automatically lowers one edge to build a tunnel exit there):
chunnel disc2_1.png
chunnel disc2_1.png (31.91 KiB) Viewed 41773 times
Disallowed (or rather, disregarded and algorithm continues search until it finds an already suitable place for tunnel exit):
chunnel disc2_2.png
chunnel disc2_2.png (38.44 KiB) Viewed 41760 times
Last edited by Roujin on 09 Feb 2009 22:38, edited 1 time in total.
* @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
Wolf01
Tycoon
Tycoon
Posts: 2016
Joined: 24 Apr 2004 10:43
Location: Venezia - Italia
Contact:

Re: Chunnel v1 r15422

Post by Wolf01 »

If tunnel entrances are enough distant I don't know why crossing tunnels should be forbidden, if they don't make your trains exit the tunnel from a wrong exit (try to build a tunnel 'inside' another with the same method you used, if you can) I think they might be allowed, but the entrance must be at least 2-3 tiles away from the intersection (so parallel tunnels should be forbidden)
This is what I mean (side view)
tunnels_crossection.PNG
tunnels_crossection.PNG (1.78 KiB) Viewed 41786 times
IMO this might open the path to other nice junctions etc, and if we might get crossing bridges too it should be the same thing, with the top bridge longer than the bottom bridge
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 3 guests