Page 2 of 5

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:42
by HackaLittleBit
EDIT not relevant

Cannot recreate your small tunnel situation.
please explain in more detail.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 22:48
by Roujin
Wolf01 wrote: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
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
We already have crossing tunnels in trunk since long time; only thing is that it's considered a cheat option. This patch should definately not change this, if the author wants to have any chance for trunk inclusion.

The point is (what I reported above and hackalittlebit already fixed) that it was possible with some dirty tricks abusing this patch for making crossing tunnels without having activated the crossing tunnels cheat.

---
If you'd like to have crossing tunnels available in multiplayer (i.e. changing it from a cheat to an advanced setting), this would be a thing for a seperate patch. Keep in mind though that it was decided to make this a cheat for a reason - it's totally unexplainable how you can have two really short tunnels crossing. So just moving it from cheats to advanced settings won't do the trick - you'd have to implement something to make sure the entrances of the tunnels are sufficiently far from each other.

Wouldn't this be a topic for a patch by you, wolf? ;)

edit: just now read your post, hackalittlebit, answering in a minute

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 23:06
by Roujin
new post to answer hackalittlebit's post:

uhm, I haven't said anything about trains crashing, or did you just test that for yourself?

here's the "small tunnel problem" in steps to create:

Step1: create this kind of terrain and build large undersea tunnel (with the newest version, you have to create that little island in the middle beforehand)
chunnel smalltunnel_1.png
chunnel smalltunnel_1.png (47.15 KiB) Viewed 8568 times
Step2: create this small tunnel
chunnel smalltunnel_2.png
chunnel smalltunnel_2.png (47.34 KiB) Viewed 8571 times
=> the two tunnels are crossing each other.

Strangely, building the small tunnel suddenly leads to me being able to raise some land in positions where it should be prohibited by the large (undersea) tunnel! Before building the small tunnel, I was forbidden to raise there, but now it suddenly works!
chunnel smalltunnel_3.png
chunnel smalltunnel_3.png (44.46 KiB) Viewed 8573 times

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 23:08
by HackaLittleBit
Wolf the situation of a tunnel in between a tunnel is not possible (at this moment). Train would come out of wrong entrance.
You can however build a bridge in between.

Re: Chunnel v1 r15422

Posted: 09 Feb 2009 23:13
by HackaLittleBit
Ok was able to reproduce it
Jee your really a champ. :bow:

Going to have a look at that now
see yah
EDIT see yah TOMORROW and many thanks HackaLittleBit
small.png
small.png (47.89 KiB) Viewed 8580 times

Re: Chunnel v1 r15422

Posted: 10 Feb 2009 14:53
by HackaLittleBit
Ok Roujin did most of your requests.

Pls check for more bugs.

Regards

HackaLittleBit

Known issues: The moment the passing_water switch is on more suitable terrain is required.
Having a look at that now.

Re: Chunnel v1 r15422

Posted: 10 Feb 2009 18:40
by HackaLittleBit
Ok I think I solved all pending issues.

No known issues anymore
Thanks everybody for their help and suggestions.
EDIT: Still some inconsistencies :oops:
will keep you informed

Re: Chunnel v1 r15422

Posted: 11 Feb 2009 12:10
by HackaLittleBit
Ok I think I solved all pending issues.
Please tell me if your not happy with the feature or if changes should be made

Again a special thanks to Roujin

Regards HackaLittleBit

Re: Chunnel v9 r15456 Cheating impossible

Posted: 12 Feb 2009 15:40
by HackaLittleBit
Removed the possibility to dynamite water above underwater tunnel.
regards HackaLittleBit

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 14:12
by Dimme
Hi hackalittlebit!

Thank you for implementing this :)

I have not tested the patch yet, but if it works fine I think it is a good addition to the possibilities of the game :D

I suppose these tunnels behave like ordinary tunnels, but how difficult will it be to give them some extra specifications? They really need to be balanced towards the bridges, and ideally, it should be possible to alter the specs via newGRF. For realism, trains entering the tunnel should go down some levels. This will make trains slow down when going up on the other side, so bridges will be better where they can be built. Maybe it can even be done graphically, so that you see that trains go down when entering a tunnel?

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 15:47
by HackaLittleBit
Hi Dimme;

You see I listened to your suggestions in signals in tunnels V7 r15294http://www.tt-forums.net/viewtopic.php?p=754341#p754341.
All these patches I make just for one purpose and that is to get some kind of signals - in - tunnels patch into trunk.
The reason I made this one is just to give some extra playing dimension.
I like to look at trains on single track (and bringing them back by tunnel).
At this moment I would like people to test it in order to submit this one to trunk asap.
I don't think I should make major changes at this moment to this patch.
It looks nice like this and that it fits in the overall game philosophy.
There is another reason for this patch and that is in the future being able to connect various maps together like model railroaders are doing now also.
With a tunnel it should be possible to overcome the synchronization problems( hide train, transfer train etc.)

Regards HackaLittleBit

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 16:01
by broodje
I must say I really like your patch. The tunnels fits beautifully in my southern UK game as a replacement for my severn bridges at Bristol :). Like you said, it fit's with the design philosophy of openttd it is a logical addition to the current tunnels.

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 16:09
by DJ Nekkid
what i could wish for is this, and it's _something_ similar...

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 16:30
by HackaLittleBit
what i could wish for is this, and it's _something_ similar...
If certain combination's would be disallowed it's no big deal.

Re: Chunnel v9 r15456

Posted: 13 Feb 2009 19:23
by DJ Nekkid
i see your point... but still, good idea :)

Re: Chunnel v9 r15456

Posted: 14 Feb 2009 08:29
by Dimme
hackalittlebit wrote:Hi Dimme;

You see I listened to your suggestions in signals in tunnels V7 r15294http://www.tt-forums.net/viewtopic.php?p=754341#p754341.
All these patches I make just for one purpose and that is to get some kind of signals - in - tunnels patch into trunk.
The reason I made this one is just to give some extra playing dimension.
I like to look at trains on single track (and bringing them back by tunnel).
At this moment I would like people to test it in order to submit this one to trunk asap.
I don't think I should make major changes at this moment to this patch.
It looks nice like this and that it fits in the overall game philosophy.
There is another reason for this patch and that is in the future being able to connect various maps together like model railroaders are doing now also.
With a tunnel it should be possible to overcome the synchronization problems( hide train, transfer train etc.)

Regards HackaLittleBit
Sure, no problem :D

Just trying to be constructive in order to get this patch in trunk. To show the opportunities. But you're right, it is probably best not to make it too big anyway. There are plenty of possibilities to alter the behaviour in later patches, and people can choose to play with it or not.

I'd really like to see this one in trunk :)

Regards Dimme.

Re: Chunnel v9 r16135

Posted: 24 Apr 2009 14:24
by 2007Alain2007
update and build only changes was the STR_ERROR
chunnelv9_r16135.patch
chunnel_v9_r16135.7z

Re: Chunnel v9 r15827

Posted: 27 Apr 2009 22:34
by nicfer
Would be cool if you could build tunnels by selecting first the starting tile then the finishing one, but that could lead to unwanted situations like skipping the crossing briges restriction or similar. Similar things could be done with bridges but it would not be possible because of the graphics. At least until someone makes a modular bridges patch, aka RCT style, but then again there's the wormhole stuff again.

Re: Chunnel v9 r15827

Posted: 04 May 2009 23:36
by 2007Alain2007
V 10 is on the frist post but you need to change lines in terraform_cmd.cpp

Code: Select all

Index: src/terraform_cmd.cpp
===================================================================
--- src/terraform_cmd.cpp	(revision 15829)
+++ src/terraform_cmd.cpp	(working copy)
@@ -303,9 +303,10 @@
 				return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
 			}
 			/* Check if tunnel would take damage */
-			if (direction == -1 && IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
+			if (IsTunnelInWay(tile, z_min * TILE_HEIGHT)) {
 				_terraform_err_tile = tile; // highlight the tile above the tunnel
-				return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
+				if (direction == -1) return_cmd_error(STR_ERROR_EXCAVATION_WOULD_DAMAGE);
+				if (direction == 1) return_cmd_error(STR_ERROR_MUST_DEMOLISH_TUNNEL_FIRST);
 			}
 			/* Check tiletype-specific things, and add extra-cost */
 			const bool curr_gen = _generating_world;
Index: src/tunnel_map.cpp
===================================================================
--- src/tunnel_map.cpp	(revision 15829)
+++ src/tunnel_map.cpp	(working copy)
@@ -41,18 +41,14 @@
 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
 {
 	TileIndexDiff delta = TileOffsByDiagDir(dir);
-	uint height;
-
-	do {
+	for (;;) {
 		tile -= delta;
 		if (!IsValidTile(tile)) return false;
-		height = GetTileZ(tile);
-	} while (z < height);
-
-	return
-		z == height &&
-		IsTunnelTile(tile) &&
-		GetTunnelBridgeDirection(tile) == dir;
+		if (GetTileZ(tile) != z) continue;
+		if (!IsTunnelTile(tile)) continue;
+		if(dir == GetTunnelBridgeDirection(tile)) return true;
+		return false;
+	}
 }

 /**
Index: src/tunnelbridge_cmd.cpp
===================================================================
--- src/tunnelbridge_cmd.cpp	(revision 15829)
+++ src/tunnelbridge_cmd.cpp	(working copy)
@@ -504,7 +504,9 @@
 	} else {
 		tunnel_in_way_dir = (TileY(start_tile) < (MapMaxX() / 2)) ? DIAGDIR_SE : DIAGDIR_NW;
 	}
-
+	if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(start_tile, start_z, tunnel_in_way_dir)) {
+		return_cmd_error(STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY);
+	}
 	end_tile = start_tile;

 	/** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/
@@ -513,18 +515,33 @@
 	int tiles = 0;
 	/** Number of tiles at which the cost increase coefficient per tile is halved */
 	int tiles_bump = 25;
+	/** Tunnel under water flag */
+	bool passing_water = false;

 	for (;;) {
 		end_tile += delta;
 		if (!IsValidTile(end_tile)) return_cmd_error(STR_TUNNEL_THROUGH_MAP_BORDER);
 		end_tileh = GetTileSlope(end_tile, &end_z);

-		if (start_z == end_z) break;
+		if (start_z == end_z && IsTunnelTile(end_tile)) return_cmd_error(STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY);

+		if (end_z > start_z || end_tileh == InclinedSlope(ReverseDiagDir(direction))) passing_water = false;
+
+		if (IsTileType(end_tile + delta, MP_WATER) && !IsWaterTile(start_tile - delta) && end_z == 0) {
+			if (GetWaterTileType(end_tile + delta) == WATER_TILE_CLEAR ||
+				GetWaterTileType(end_tile + delta) == WATER_TILE_COAST) passing_water = true;
+		}
+
 		if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(end_tile, start_z, tunnel_in_way_dir)) {
 			return_cmd_error(STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY);
 		}

+		if (start_z == end_z && !passing_water) {
+			/* Don't allow tunnel inbetween existing tunnel */
+			if (IsTunnelInWayDir(end_tile, start_z, direction)) return_cmd_error(STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY);
+			break;
+		}
+
 		tiles++;
 		if (tiles == tiles_bump) {
 			tiles_coef++;
Index: src/water_cmd.cpp
===================================================================
--- src/water_cmd.cpp	(revision 15829)
+++ src/water_cmd.cpp	(working copy)
@@ -355,6 +355,9 @@
 				return_cmd_error(STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP);
 			}

+			/* Don't allow water to be cleared above underwater tunnels */
+			if (IsTunnelInWay(tile, 0)) return_cmd_error(STR_ERROR_ANOTHER_TUNNEL_IN_THE_WAY);
+
 			/* Make sure no vehicle is on the tile */
 			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;



Re: Chunnel v10 r16237

Posted: 18 May 2009 21:28
by Sensation Lover
hi all,

can someone provide even a working ziped Open TTD folder with the under water tunnel and signals simulation on bridges and tunnels please for those like me who don't understand nothing of patching even if you draw an explicit scheme of how to do it. Pretty Pleeeeease! :bow: