Page 1 of 5

Chunnel V23 r27765

Posted: 09 Feb 2009 02:44
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.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 10:28
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...

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 12:47
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...

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 12:48
by Roujin
screenshots #4 and #5

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 12:55
by HackaLittleBit
Thanks Roujin

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

Split patch in two see above

regards.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 13:17
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.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 13:37
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.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 13:43
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?

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 14:44
by HackaLittleBit
Ok about this diagonal building I fixed that.
see patch and foto

regards

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 15:12
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)

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 15:25
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

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 16:34
by Thief^
Can I suggest that underwater tunnels be more expensive than normal tunnels?

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 19:20
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

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 21:19
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

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 21:46
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.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 21:58
by HackaLittleBit
Got it Will have a look at it

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:10
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 42066 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 42070 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 42067 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:

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:19
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

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:21
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 42009 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 41996 times

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:36
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 42022 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