Project: Subway

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
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Project: Subway

Post by technosnorunt58 »

Hi I am new here and I would like to start a project to create subways in OpenTTD.
If you would like to be a coder or drawer poast here.
If you do theise are REAL subway models.
EDIT: I can/will draw.
Updates:
Last edited by technosnorunt58 on 09 Nov 2008 14:02, edited 3 times in total.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: Project: Subway

Post by DJ Nekkid »

there is a whole lot of metro/subway trains included in the 2cc-set, and we would love to have more if you want to draw:). However; your initial thread seem to be placed in the dev section, and not the grapics section...

Getting "underground" building into OTTD however is somewhat more difficult. There is a couple of ideas out there, but none of them has been acted on, and the devs have not made any "official" statements (that i know of), that such a project have been started.

The closest things is probably Belugas' (iirc) attempt to get signals on bridge tiles. (And i __think__ that can be adopted to tunnels at some point? :))
Member of the
ImageImage
User avatar
Kanibal
Traffic Manager
Traffic Manager
Posts: 159
Joined: 25 Jan 2005 20:08
Contact:

Re: Project: Subway

Post by Kanibal »

The easiest way to simulate a kind of subway that I've found is to use trams on a lower level to the city and only leaving tunnels for corners and the station stops.

All that would really require is some kind of 'subway train' graphic that runs on tram tracks.
Image
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Project: Subway

Post by Yexo »

technosnorunt58 wrote:Hi I am new here and I would like to start a project to create subways in OpenTTD.
If you would like to be a coder or drawer poast here.
If you do theise are REAL subway models.

Updates:
So what are you going to do yourself? If you want other to help, your best chance it to make a good start (ie code a patch) and show it off. If others like the way you implemented it, they might help with coding and or graphics.
User avatar
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Re: Project: Subway

Post by technosnorunt58 »

I do not know how to code that much. :(
Don't some subways go above ground also? :?
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Project: Subway

Post by CommanderZ »

They in fact go only above ground in OTTD :roll:
audigex
Tycoon
Tycoon
Posts: 2056
Joined: 09 Dec 2007 21:28
Contact:

Re: Project: Subway

Post by audigex »

Its a nice idea and I hope it gets implemented, but it will be a lot of work...

Drawing the sprites is easy enough - creating an actual underground, that's not so easy :(
Jon
User avatar
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Re: Project: Subway

Post by technosnorunt58 »

Sure it is!!! All we need to do is make everything semi-transparent like buildings, roads, grass, trees, and water. And code the underground so things on top can go on it.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Project: Subway

Post by Roujin »

Uhm, methinks that you should leave the judging if something is easy or not to the people who can code.
You can draw all sorts of things for OpenTTD, that's never difficult (note - I do not mean to belittle the work of artists!). You could also draw space shuttles, tornados and whatnot - no problem. The difficult thing is always how to code it.
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
audigex
Tycoon
Tycoon
Posts: 2056
Joined: 09 Dec 2007 21:28
Contact:

Re: Project: Subway

Post by audigex »

That's my point.

One possible way could be to have a second "map" of tiles for the underground, not viewable on the standard view, and "linking" stations that go between the underground and above ground.

Eg a 1 tile entrance above ground that creates a below ground 4x4 2-"level" station for subway trains; kinda like an ICE system.

The two levels (one for NS and one for EW traffic could just share tiles but with no collision detection unless trains are heading on the same plane.

That would be doable, but it will most likely involve editing large swathes of pathfinder etc and the drawing of the map... a lot of work. That's not to say it can't be done - but you would have to find someone prepared to do a lot of work for it on the coding front.
Jon
User avatar
Expresso
Tycoon
Tycoon
Posts: 1760
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Re: Project: Subway

Post by Expresso »

Best way is not to go for a workaround, as that might create issues in the future.

To get underground levels you need a completely different map array (to curb memory consumption). This translates to changeing about half of openttd (quite a lot of work, especially since most/all devs are either students or have day jobs).

Lets see what changes need to be done:
  • Make a wrapper class for the TileIndex (the tileindex is a unique value representing the offset in the map array), to support both new and old tileindexes (this is step 1 of your project, also the easiest step).
  • Make a wrapper class for the map array and populate it with the functions which calculate all kinds of things which are needed by the various parts of openttd (quite easy, but lots of work). Make sure the class functions are used instead of the global ones.
  • Write the replacement map array (basically a Memory pool storing 16x16 or 8x8 blocks of tiles). Make sure it's accessed properly (otherwise havoc will ensue once you're using it).
  • Get rid of the runtime TileIndex conversion, by providing converted versions of the map class functions (relatively easy, but quite a lot). NOTE: you cannot get rid of the old ones, since you might need them to load scenarios/savegames from previous versions.
At this point you still haven't got a 3D map array (the thing you need for underground, but the basics are there... this is quite some subversion revisions further, but everything should be doable up to this point. There are no visible results at this point, except an openttd which might be a bit slower. :(

This allows for non-uniform maps (well... within certain limits). For this lots of additional work is required, but at the moment that isn't of interest... technosnorunt58 wanted subways, and for that we need quite a bit of additional work:
  • At this point layers need to be stacked in the map array, implementing this shouldn't be much of a problem. There are a few approaches to handling this, each having its own advantages and disadvantages.
  • Get the new TileIndex an additional nybble (for the height).
This was the easy part, now for the hard part. This part is the most work, and probably not as easy either.
  • Split out tunnel and bridge code, for easy conversion later. Is this really needed?
  • Adapt various checks throughout the code to see what's above/below the current tile (lots of work).
  • Adapt the viewport to take the 3D map array into account.
  • Put all tiles on different heights (according to their tile height). However, still treat the map as 2D (makes life easier).
  • Adapt the map generator for the 3D map.
  • Correct the tunnel and bridge functions to actually put rails/roads on the map in the appropriate 3D tile (converters for savegames).
  • Adapt the map functions to make use of the 3D functionality (underground/overground rails).
Still nothing visible, though the worst part is done at this point (a year further, with some luck). Still no underground. That comes now. With this part the artists are of a little use.
  • First the UI needs some love. Have you dreamt up an easy to use way to edit with multiple layers, without behaving like locomotion? That needs to be implemented at this point.
  • Make openttd aware of what's underground and above ground and stop rendering when the border is reached (underground renders from below to the surface, and above ground renders from the surface to the top of the map array.
Why all this? Well, if you go for multiple layers, you should do it right from the start instead of discovering some day that it doesn't quite work as well as expected.

NOTE: I'm not a dev, but have take a few looks at the code.
Antdovu
Engineer
Engineer
Posts: 19
Joined: 28 May 2008 19:54

Re: Project: Subway

Post by Antdovu »

Mostly I agree with what Expresso said but some of what he said isn't necessarily true for every reasonable approach.

The main problems in my opinion:
  1. It isn't too hard to get something working. It is hard to make it work well, be reasonable fast and not use a huge amount of memory.
  2. You need a good way to be able to edit in 3 dimensions.
  3. You need a good way to render the world in 3 dimensions fast.
  4. Huge amount of existing code might need to be modified. This will likely introduce a swarm of huge bugs.
My thoughts about the possible implementation:
  1. Could use a rolling amount of layers (keeps memory requirement down, allows flexible terrain, makes rendering difficult)
  2. The views could be split into 2: above ground (forests, towns, bridges, etc) and below the ground (tunnels, subway, under the sea, underground stations).
  3. You don't necessarily need to be compatible with the old map other than allow converting the old into the new when loading.
I am sure that it could be done but it would likely need more than a couple of people working on it together and a lot of time. If the project will ever be undertaken then I would highly suggest making a formal design for it before any coding.
User avatar
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Re: Project: Subway

Post by technosnorunt58 »

It would need to intersect with tunnles already there.
Witch in my mind would be a possable glitch.
audigex
Tycoon
Tycoon
Posts: 2056
Joined: 09 Dec 2007 21:28
Contact:

Re: Project: Subway

Post by audigex »

That's why I suggested foax levels

You can't actually choose what levels the track is on (this reduces some of the workload dramatically)

Instead trains travelling NS are on "level 1" which is always above "level 2" (EW trains); these two tracks can then cross each other with no issues

Diagonal tracks are visualised as "slopes" or similar, to allow trains to change direction - these cannot intersect with either NS, SW or other diagonal tracks and are strictly 1-track-per-tile.

It's workable in either format; and would IMO be a great addition to the game in the realism it can offer (buses always struggle to cope with large cities full of passengers)... I just don't think anyone has that much spare time on their hands.
Jon
User avatar
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Re: Project: Subway

Post by technosnorunt58 »

So should we start?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Project: Subway

Post by DaleStan »

Only if you're using the royal we there.
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
technosnorunt58
Engineer
Engineer
Posts: 79
Joined: 09 Nov 2008 00:59

Re: Project: Subway

Post by technosnorunt58 »

DaleStan wrote:Only if you're using the royal we there.
What does that mean???
User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Project: Subway

Post by Gremnon »

The royal we, where we is used instead of I.
To put it bluntly, DaleStan's not interested, and tbh, I don't think any else is either.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Project: Subway

Post by planetmaker »

technosnorunt58 wrote:So should we start?
It's up to you on how to spend your time. If properly done, it may be an awesome patch.

For inspiration have a look at http://devs.openttd.org/~smatz/3d/
User avatar
CommanderZ
Tycoon
Tycoon
Posts: 1872
Joined: 07 Apr 2008 18:29
Location: Czech Republic
Contact:

Re: Project: Subway

Post by CommanderZ »

planetmaker wrote:
technosnorunt58 wrote:So should we start?
It's up to you on how to spend your time. If properly done, it may be an awesome patch.

For inspiration have a look at http://devs.openttd.org/~smatz/3d/
This is amazing, I never know someone actually tried to code this. Thanks for a link.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 16 guests