[Patch] Canal tunnels
Moderator: OpenTTD Developers
[Patch] Canal tunnels
I got stuck in a game this week and was inspired to make some water/canal tunnels (as mentioned in http://www.tt-forums.net/viewtopic.php? ... el#p615367 etc.)>
Features:
* New button on the dock toolbar to build water tunnels
* Ships can travel down the water tunnels.
Still needed:
* Graphical glitches at tunnel entry/exit
* Pathfinding - I don't really know where to begin making the pathfinder look down tunnels. Turning on YAPF for ships throws an assertion, but I don't understand YAPF enough to know why. This is what I'm working on now.
* Sprites - I'm using the road sprites for now. I'm no artist :)
I suspect the graphical glitches are caused by using the wrong values for _tunnel_fractcoord_n(dir) in VehicleEnter_TunnelBridge (tunnelbridge_cmd.cpp, line ~1440). Twiddling the numbers helps some, but I don't know the rationalisation for the existing numbers, so I don't know how permenent a solution that is. The correct values probably also depend on nwegrf ship sizes. Can somebody enlighten me?
Attached is a patch against r11487.
Also attached is a savegame to demonstrate the work so far.
Features:
* New button on the dock toolbar to build water tunnels
* Ships can travel down the water tunnels.
Still needed:
* Graphical glitches at tunnel entry/exit
* Pathfinding - I don't really know where to begin making the pathfinder look down tunnels. Turning on YAPF for ships throws an assertion, but I don't understand YAPF enough to know why. This is what I'm working on now.
* Sprites - I'm using the road sprites for now. I'm no artist :)
I suspect the graphical glitches are caused by using the wrong values for _tunnel_fractcoord_n(dir) in VehicleEnter_TunnelBridge (tunnelbridge_cmd.cpp, line ~1440). Twiddling the numbers helps some, but I don't know the rationalisation for the existing numbers, so I don't know how permenent a solution that is. The correct values probably also depend on nwegrf ship sizes. Can somebody enlighten me?
Attached is a patch against r11487.
Also attached is a savegame to demonstrate the work so far.
- Attachments
-
- WaterTunnels_NoPathfind r11487.patch
- v0.1 patch agains r11487
- (21.47 KiB) Downloaded 257 times
-
- WaterCannal Test 1.sav
- (25.77 KiB) Downloaded 174 times
-
- Renside Transport, 24th May 1951.png (64.52 KiB) Viewed 9557 times
Re: [Patch] Canal tunnels
I think that is caused by the tunnel is too small for the ship sizes, the road tunnel is too small for even a medium sized ship, doesnt it, or there is a bigger problem witch lies here?d37373 wrote:* Graphical glitches at tunnel entry/exit
The sprite witch is drawn on the top of the tunnelhead base, should be a lot bigger than the road one. And for the ship is drawn on previsious tile, the ship should appear later, if its possible.
But as you can see, a ship is bigger even a full tile, the ship should be cutted to two parts..
Anyway this is a cool patch:)
- Attachments
-
- test.PNG (6.4 KiB) Viewed 9241 times
Re: [Patch] Canal tunnels
I think you'll find the tunnel glitch is a known one all around. I can't remember the details, but I know it happens with the train tunnels too. Its a TTD problem I believe.
Re: [Patch] Canal tunnels
Just try george`s long vehicles...Ben_K wrote:I think you'll find the tunnel glitch is a known one all around. I can't remember the details, but I know it happens with the train tunnels too. Its a TTD problem I believe.
Re: [Patch] Canal tunnels
Only 'thing' is that in case of the long vehicles, the long vehicles are bugged and not (O)TTD(P). This because the NewGRF specs say the vehicles can have a maximum size and when that is exceeded, glitches will occur. The same as when you would make a building sprite larger than the tile itself. It is bound to give glitches.thgergo wrote:Just try george`s long vehicles...Ben_K wrote:I think you'll find the tunnel glitch is a known one all around. I can't remember the details, but I know it happens with the train tunnels too. Its a TTD problem I believe.
Re: [Patch] Canal tunnels
Probably makes more sense to do aqueducts first, seeing they're quite a bit more common.
Re: [Patch] Canal tunnels
Aqueduct are more realistic, too. I think no one in real live will make a tunnel for a super petroleum tankerNCarlson wrote:Probably makes more sense to do aqueducts first, seeing they're quite a bit more common.

But this thread is for tunnels and not for "what will be better"

So: good idea and I hope you'll write a patch which have good chances (cooding style and so on) to get into trunk.
-BigBB
OpenTTD-patch(es) in development: missing shores (new version of: completely shore), road lamps for each position
- athanasios
- Tycoon
- Posts: 3138
- Joined: 23 Jun 2005 00:09
- Contact:
Re: [Patch] Canal tunnels
Finally someone patched this.
My only suggestion is make tunnels taller (>= 2 height). (Repeating myself here, requesting very hard things...)
![Pleased :]](./images/smilies/pleased.gif)
My only suggestion is make tunnels taller (>= 2 height). (Repeating myself here, requesting very hard things...)
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
Re: [Patch] Canal tunnels
I'll probably get on to aqueducts/bridges once I've got the tunnels working to my satisfaction. Tunnels are a little simpler to code, so I started there.
@thgergo - where is that tunnel graphic from, and who made it? It looks like just what I need.
@athanasios - Making tunnels 2 high may also solve the graphical glitches. On the other hand, I'm not sure how easy it would be to code - might be simple, might not.
@ BigBB - I home that it will go into trunk too, but it's not ready yet! If anyone wants to help or has suggestions on my coding style etc. feel free.
@thgergo - where is that tunnel graphic from, and who made it? It looks like just what I need.
@athanasios - Making tunnels 2 high may also solve the graphical glitches. On the other hand, I'm not sure how easy it would be to code - might be simple, might not.
@ BigBB - I home that it will go into trunk too, but it's not ready yet! If anyone wants to help or has suggestions on my coding style etc. feel free.
- Born Acorn
- Tycoon
- Posts: 7596
- Joined: 10 Dec 2002 20:36
- Skype: bornacorn
- Location: Wrexham, Wales
- Contact:
Re: [Patch] Canal tunnels
Well, you never know, if anyone with the money wanted such a piece of infrastructure, and it was proved to be economically feasible, it would most likely be done.BigBB wrote:Aqueduct are more realistic, too. I think no one in real live will make a tunnel for a super petroleum tanker.
Re: [Patch] Canal tunnels
The are water tunnels:
Lahn: http://www.weilburg-lahn.info/sehwert/schifft.htm
Canal du midi: http://de.wikipedia.org/wiki/Bild:FR06_P1110625.jpg
Canal de la Marne au Rhin: http://de.wikipedia.org/wiki/Bild:Rhein ... Tunnel.jpg
Sapperton Tunnel: http://en.wikipedia.org/wiki/Sapperton_Canal_Tunnel
Hddersfield Narrow Canal: http://en.wikipedia.org/wiki/Huddersfield_Narrow_Canal
Lahn: http://www.weilburg-lahn.info/sehwert/schifft.htm
Canal du midi: http://de.wikipedia.org/wiki/Bild:FR06_P1110625.jpg
Canal de la Marne au Rhin: http://de.wikipedia.org/wiki/Bild:Rhein ... Tunnel.jpg
Sapperton Tunnel: http://en.wikipedia.org/wiki/Sapperton_Canal_Tunnel
Hddersfield Narrow Canal: http://en.wikipedia.org/wiki/Huddersfield_Narrow_Canal
I like to look at great maps and see how things flow. A little like a finished model railway, but it is evolving and actually never finished. http://www.simutrans.com
- Born Acorn
- Tycoon
- Posts: 7596
- Joined: 10 Dec 2002 20:36
- Skype: bornacorn
- Location: Wrexham, Wales
- Contact:
Re: [Patch] Canal tunnels
Yes. It is known they exist for small narrowboats, and smaller boats in general, but not for panamax ships.
- Sir A. Boey
- Transport Coordinator
- Posts: 299
- Joined: 17 Nov 2006 17:40
- Location: Everywhere and nowhere
Re: [Patch] Canal tunnels
you could restrict the panama size ships from going into these tunnels...
I don't know much about coding but a coach isn't able to go into a traintunnel neither
so that's what I mean with restrictions...
Alow the small passenger ships to pass but not the cargo ships.I really like the idea
that and the one with canal bridges or the aquaducts, not very common in real life but
It would certainly make the game more enjoyable and it would look nicer 2.
I don't know much about coding but a coach isn't able to go into a traintunnel neither
so that's what I mean with restrictions...
Alow the small passenger ships to pass but not the cargo ships.I really like the idea
that and the one with canal bridges or the aquaducts, not very common in real life but
It would certainly make the game more enjoyable and it would look nicer 2.
_____________# If you believe in it, you can achieve it" # ____________
__________________# Check out My Closed Platform #___________________
Re: [Patch] Canal tunnels
But the ships in openttd are not panama size ships - panamaxes have displacement of around 65000 tons, while ships in OpenTTD may have around 500-1000 tons (guessing by its capacities), which is much smaller than that, although still probably too large for small water tunnels as mentioned in examples above (I guess max 50 ton ship or 50 passenger ship could fit in these tunnels).
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)
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)
-
- Engineer
- Posts: 45
- Joined: 08 Nov 2005 12:33
- Location: Bergen
- Contact:
Re: [Patch] Canal tunnels
The Stad Ship Tunnel is planned in Norway and is supposed to be 1800 metres long, 33 metres high, 23 metres wide and 12 metres deep.Born Acorn wrote:Yes. It is known they exist for small narrowboats, and smaller boats in general, but not for panamax ships.
Not exactly panamax, but not exactly narrowboat either

- athanasios
- Tycoon
- Posts: 3138
- Joined: 23 Jun 2005 00:09
- Contact:
Re: [Patch] Canal tunnels
That's interesting and valid reason for this patch. 12 meters is big depth.
But we should not introduce such tunnels prior to the date that this one is finished. For earlier days tunnels should be smaller (allowing only small ships).
But we should not introduce such tunnels prior to the date that this one is finished. For earlier days tunnels should be smaller (allowing only small ships).
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
"If no one is a fool I am also a fool." -The TTD maniac.
I prefer to be contacted through PMs. Thanks.
Re: [Patch] Canal tunnels
Which would be great. If only ships had a size.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Re: [Patch] Canal tunnels
Best you can do is either add some field to the newGRF or apply some guess-o-matic function to "calculate" size given the cargo capacity (i.e. something like "anything with capacity under 150 units of cargo = small").DaleStan wrote:Which would be great. If only ships had a size.
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)
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)
Who is online
Users browsing this forum: Ahrefs [Bot] and 10 guests