[Patch] Canal tunnels

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

Post Reply
User avatar
d37373
Engineer
Engineer
Posts: 21
Joined: 23 Oct 2006 12:11

[Patch] Canal tunnels

Post by d37373 »

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.
Attachments
WaterTunnels_NoPathfind r11487.patch
v0.1 patch agains r11487
(21.47 KiB) Downloaded 190 times
WaterCannal Test 1.sav
(25.77 KiB) Downloaded 125 times
Renside Transport, 24th May 1951.png
Renside Transport, 24th May 1951.png (64.52 KiB) Viewed 8661 times
rabbit67890
Engineer
Engineer
Posts: 72
Joined: 23 Sep 2007 09:57

Re: [Patch] Canal tunnels

Post by rabbit67890 »

wow :)
User avatar
thgergo
Route Supervisor
Route Supervisor
Posts: 391
Joined: 29 Mar 2005 12:44
Location: Hungary

Re: [Patch] Canal tunnels

Post by thgergo »

d37373 wrote:* Graphical glitches at tunnel entry/exit
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?
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
test.PNG (6.4 KiB) Viewed 8345 times
Image
Image
User avatar
Ben_K
Tycoon
Tycoon
Posts: 1166
Joined: 01 Jun 2006 15:15
Location: Sydney, AUS

Re: [Patch] Canal tunnels

Post by Ben_K »

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.
User avatar
thgergo
Route Supervisor
Route Supervisor
Posts: 391
Joined: 29 Mar 2005 12:44
Location: Hungary

Re: [Patch] Canal tunnels

Post by thgergo »

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.
Just try george`s long vehicles...
Image
Image
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: [Patch] Canal tunnels

Post by Rubidium »

thgergo wrote:
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.
Just try george`s long vehicles...
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.
NCarlson
Traffic Manager
Traffic Manager
Posts: 200
Joined: 18 Dec 2002 17:49

Re: [Patch] Canal tunnels

Post by NCarlson »

Probably makes more sense to do aqueducts first, seeing they're quite a bit more common.
BigBB
Engineer
Engineer
Posts: 106
Joined: 07 Aug 2007 20:39

Re: [Patch] Canal tunnels

Post by BigBB »

NCarlson wrote:Probably makes more sense to do aqueducts first, seeing they're quite a bit more common.
Aqueduct are more realistic, too. I think no one in real live will make a tunnel for a super petroleum tanker :). Maybe we have anytimes seperated ships for open sea and for inland water-ways...

But this thread is for tunnels and not for "what will be better" :wink: ...
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
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: [Patch] Canal tunnels

Post by athanasios »

Finally someone patched this. :]
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.
User avatar
d37373
Engineer
Engineer
Posts: 21
Joined: 23 Oct 2006 12:11

Re: [Patch] Canal tunnels

Post by d37373 »

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.
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Re: [Patch] Canal tunnels

Post by Born Acorn »

BigBB wrote:Aqueduct are more realistic, too. I think no one in real live will make a tunnel for a super petroleum tanker :).
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.
Image
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Re: [Patch] Canal tunnels

Post by prissi »

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
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Re: [Patch] Canal tunnels

Post by Born Acorn »

Yes. It is known they exist for small narrowboats, and smaller boats in general, but not for panamax ships.
Image
User avatar
Sir A. Boey
Transport Coordinator
Transport Coordinator
Posts: 299
Joined: 17 Nov 2006 17:40
Location: Everywhere and nowhere

Re: [Patch] Canal tunnels

Post by Sir A. Boey »

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.
Image
_____________# If you believe in it, you can achieve it" # ____________
__________________# Check out My Closed Platform #___________________
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: [Patch] Canal tunnels

Post by Bilbo »

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)
charlymorton
Engineer
Engineer
Posts: 45
Joined: 08 Nov 2005 12:33
Location: Bergen
Contact:

Re: [Patch] Canal tunnels

Post by charlymorton »

Born Acorn wrote:Yes. It is known they exist for small narrowboats, and smaller boats in general, but not for panamax ships.
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.

Not exactly panamax, but not exactly narrowboat either :)
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Re: [Patch] Canal tunnels

Post by athanasios »

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).
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.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: [Patch] Canal tunnels

Post by DaleStan »

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

Re: [Patch] Canal tunnels

Post by Bilbo »

DaleStan wrote:Which would be great. If only ships had a size.
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").
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)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 18 guests