Underground/Metro

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
HCF
Engineer
Engineer
Posts: 1
Joined: 08 Jul 2014 07:22

Underground/Metro

Post by HCF »

I have figured out a way to simulate metro/underground trains without having to rewrite the whole game, but of course it's not very simple at all (or someone else would have done it by now).

Ok, so metro systems. The problem that we have is as follows; we cannot have a new Z-level on which to lay track and such. There is however an unused Z-level; the sky.
After playing a game where I used helicopters to supplement buses in the inner city, I realised that with some creative coding it should be possible to create a system where when a train enters a 'Metro tunnel' it gets 'deleted', and simultaneously we procedurally generate a 'helicopter' procedurally which contains all of the information of the 'deleted' train at the metro tunnel ( a quick hack of a train depot and a heliport should provide this) which can the fly 'underground' (animate the sprite several pixels below its real location) to a metro station (modified heliport) or out of a 'Metro tunnel' where we delete the 'helicopter' and re-generate the train from earlier.

I'm not sure if things such as points or signals could be simulated 'underground' easily (perhaps each metro tunnel stores an array of what there is in that particular tunnel) but I think this might be a good starting point for approaching metro systems.

I have experience coding, but I have never done anything with openttd, so I have no idea where to start such a project.

Thoughts?
User avatar
kamnet
Moderator
Moderator
Posts: 8705
Joined: 28 Sep 2009 17:15
Location: Eastern KY
Contact:

Re: Underground/Metro

Post by kamnet »

It could be worth a shot.

If you're not aware, there has been a fairly close attempt at an underground levels patch that gave you four separate "underground" levels to work with, and a means to unify stations on all four levels. What it lacked was a means to connect and transfer vehicles from one layer to the next, and the patch author stopped working on it due to lack of interest from OpenTTD devs to finish the project for him. At least one experimental OpenTTD build was created from it if you want to try it out immediately.
User avatar
FLHerne
Tycoon
Tycoon
Posts: 1543
Joined: 12 Jul 2011 12:09
Location: St Ives, Cambs, UK

Re: Underground/Metro

Post by FLHerne »

Sounds overly hacky in my opinion - someone's idea of just allocating extra strips of map-array to represent the inside of tunnels seems far less likely to become a horrible mess. :P

Trains have a lot of state that aircraft don't (and one 'train' is made up of many C++ 'Train' objects, one for each loco/wagon). Adding all this to the aircraft class would be ridiculous, so slightly saner would be to give the aircraft a pointer to the actual train and 'teleport' (well, instantaneously change its position and probably other stuff) the latter when your aircraft got to the exit point. Drawing a sprite for it doesn't make sense - if it's underground, you can't see it (to "animate the sprite several pixels below its real location" wouldn't make it look 'underground' in any way, just a few tiles further south), and if you can see it then its on the surface and doesn't need to be a bizarre fake-train aircraft at all.

But then you're not really doing anything with the aircraft - it doesn't need sprites, altitude, cargo, or just about anything else, so just waiting for a bit (depending on the invisible-tunnel length) before moving the train would have the same effect.

I lost you at "I'm not sure if things such as points or signals could be simulated 'underground' easily (perhaps each metro tunnel stores an array of what there is in that particular tunnel) but I think this might be a good starting point for approaching metro systems." - aircraft don't use those things, and that exact characteristic (not needing to have extra map-array values for underground vehicles) seems to be your argument for using them in the first place. If you add extra information for underground tunnels, then you can just use ordinary sensible trains; that last paragraph seems to contradict (and makes rather more sense than IMO) the other thing you suggested.
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Underground/Metro

Post by Eddi »

it's not only overly hacky, it's also completely missing the point. the issue was never putting the train somewhere which isn't on the surface. that can already be done and is how bridges and tunnels currently work. the issue is putting the rails somewhere, and a useful user interface for construction and display of underground tracks.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 5 guests