Railroad tracks

Hi! I thought some railroad tracks would be nice in C:DDA. So this is just an idea about railroad tracks for C:DDA. I designed some rough map tiles in size 24×24, they (hopefully) connect to each other nicely.
This is just a rough draft. Suggestions and more stuff is welcome. I don’t know yet how to put these railroad tracks into the game, even if just for testing.

Straight rails:

..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..

Straight left rail:

..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............

Straight right rail:

.............-x-----x-..
..............x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..

Straight rails, dead end:

........................
........................
..^^^^^^^^^..^^^^^^^^^..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..SSSSSSSSS..SSSSSSSSS..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..

Straight left rail, dead end:

........................
........................
..^^^^^^^^^.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..SSSSSSSSS.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............

Straight right rail, dead end:

........................
........................
.............^^^^^^^^^..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............SSSSSSSSS..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..
.............-x-----x-..
.............^x^^^^^x^..

Rails over street:

..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
   x     x    x     x   
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..
..-x-----x-..-x-----x-..
..^x^^^^^x^..^x^^^^^x^..

Outer curve:

........................
........................
........^^|^|^|^|^|^|^|^
......^|xxxxxxxxxxxxxxxx
....\^xx^^|^|^|^|^|^|^|^
....^x^|^^|^|^|^|^|^|^|^
...^x^\^|^|^|^|^|^|^|^|^
...-x-^\|^|^|^|^|^|^|^|^
..^x^^--\||^|^|^|^|^|^|^
..^x^^^^-\xxxxxxxxxxxxxx
..-x-----x|^|^|^|^|^|^|^
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^.............

Inner curve:

........................
........................
........................
........................
........................
........................
........................
........................
........................
........................
........................
........................
........................
...................^^^|^
.................^|xxxxx
...............\^xx^^^|^
...............^x^|^^^|^
..............^x^\^|^^|^
..............-x-^\|^^|^
.............^x^^--\|^|^
.............^x^^^^--xxx
.............^x^^^^^x-|^
.............-x-----x-..
..............x^^^^^x^..

Curved rails:

........................
........................
........^^|^|^|^|^|^|^|^
......^|xxxxxxxxxxxxxxxx
....\^xx^^|^|^|^|^|^|^|^
....^x^|^^|^|^|^|^|^|^|^
...^x^\^|^|^|^|^|^|^|^|^
...-x-^\|^|^|^|^|^|^|^|^
..^x^^--\||^|^|^|^|^|^|^
..^x^^^^-\xxxxxxxxxxxxxx
..-x-----x|^|^|^|^|^|^|^
..^x^^^^^x^.............
..-x-----x-.............
..^x^^^^^x^........^^^|^
..-x-----x-......^|xxxxx
..^x^^^^^x^....\^xx^^^|^
..-x-----x-....^x^|^^^|^
..^x^^^^^x^...^x^\^|^^|^
..-x-----x-...-x-^\|^^|^
..^x^^^^^x^..^x^^--\|^|^
..-x-----x-..^x^^^^--xxx
..^x^^^^^x^..^x^^^^^x-|^
..-x-----x-..-x-----x-..
..^x^^^^^x^...x^^^^^x^..

Key (actualy symbol may vary):
“.” = ground (may be earth and grass like on a field or anything else which is walkable) (movecost: 100)
“ ” = asphalt (movecost: 100)
“-”, “|” or “\” = railroad tie (new) (movecost: 100)
“x” = railroad track (new) (movecost: 100)
“^” = pile of rubble (movecost: 200)
“S” = buffer stop (new) (movecost: 150) (can be smashed for two-by-fours, nails and splintered wood)

Here’s some JSON for the new terrain types, could be used in a mod’s terrain.json:

[
    {
        "type" : "terrain",
        "id" : "t_railroad_track",
        "name" : "railroad track",
        "symbol" : "x",
        "color" : "ltgray",
        "move_cost" : 2,
        "flags" : ["TRANSPARENT"]
    },{
        "type" : "terrain",
        "id" : "t_buffer_stop_h",
        "name" : "buffer stop",
        "symbol": "S",
        "color" : "brown",
        "move_cost" : 3,
        "flags" : ["BASHABLE", "TRANSPARENT", "NOITEM", "MOUNTABLE"],
        "bash": {
            "str_min": 4, "str_max": 12,
            "sound": "crack.",
            "sound_fail": "whump.",
            "ter_set": "t_railroad_tie_h",
            "items": [
                { "item": "2x4", "amount": 5, "minamount": 2},
                { "item": "nail", "amount": 8, "minamount": 3},
                { "item": "splinter", "amount": 2 }
            ]
        }
    },{
        "type" : "terrain",
        "id" : "t_buffer_stop_v",
        "name" : "buffer stop",
        "symbol": "S",
        "color" : "brown",
        "move_cost" : 3,
        "flags" : ["BASHABLE", "TRANSPARENT", "NOITEM", "MOUNTABLE"],
        "bash": {
            "str_min": 4, "str_max": 12,
            "sound": "crack.",
            "sound_fail": "whump.",
            "ter_set": "t_railroad_tie_v",
            "items": [
                { "item": "2x4", "amount": 5, "minamount": 2},
                { "item": "nail", "amount": 8, "minamount": 3},
                { "item": "splinter", "amount": 2}
            ]
        }
    },{
        "type" : "terrain",
        "id" : "t_railroad_tie_h",
        "name" : "railroad tie",
        "symbol" : "-",
        "color" : "brown",
        "move_cost" : 2,
        "flags" : ["TRANSPARENT","FLAT"]
    },{
        "type" : "terrain",
        "id" : "t_railroad_tie_v",
        "name" : "railroad tie",
        "symbol" : "|",
        "color" : "brown",
        "move_cost" : 2,
        "flags" : ["TRANSPARENT","FLAT"]
    },{
        "type" : "terrain",
        "id" : "t_railroad_tie_d1",
        "name" : "railroad tie",
        "symbol" : "/",
        "color" : "brown",
        "move_cost" : 2,
        "flags" : ["TRANSPARENT","FLAT"]
    },{
        "type" : "terrain",
        "id" : "t_railroad_tie_d2",
        "name" : "railroad tie",
        "symbol" : "\\",
        "color" : "brown",
        "move_cost" : 2,
        "flags" : ["TRANSPARENT","FLAT"]
    }
]

[hr]
I don’t think this is matured enough yet to build actual railroads with these. Some map tiles are still missing. But I think it’s a good start.

I do this because I think some railroad tracks would be nice to have in the game. The railroad tracks may have some use in the game—to slow down stupid monsters and—like streets—for orientation.

+1

Awesome, armored death train main base with a vehicle bay for my lootrunner please.

sounds like an awesome idea

Sweet! Now that you mention it, this IS something that is missing which we would have.

Have you considered some random traincars parked on them?

If this goes in, it certainly needs train cars and things to explore. And perhaps drive.

yeah, that would be awesome. driving trains… xD … maybe even have coal as fuel?, that would be fun

Thank you. I am happy about your positive response. But please remember this thread is only about railroad tracks. I won’t do any railroad vehicles. Also railroad vehicles are off-topic here (please open a new topic if you insist).

Okay, here is a small expansion of this concept. Railroad bridges.

Straight rail bridge:

~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~
~#-x-----x-##-x-----x-#~
~##x#####x####x#####x##~

Straight left rail bridge:

~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~
~#-x-----x-#~~~~~~~~~~~~
~##x#####x##~~~~~~~~~~~~

Straight right rail bridge:

~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~
~~~~~~~~~~~~#-x-----x-#~
~~~~~~~~~~~~##x#####x##~

It may be a bit difficult to read, so you may want to enlarge the font or view it in your text editor with a better font.

Key:
“#” are metal grates (already in game).
“~” is deep water (already in game).
“-” is a piece of a railroad tie (new).
“x” is a piece of a railroad track (new).

PS: I may soon attempt to actually code some of these map tiles directly in C++. It does not look so difficult, after all. :slight_smile:

I was successful in messing around with mapgen_functions.cpp (and related files) and created some new map tiles!

I have added:

[ul][]straight tiles
[
]curved tiles
[]buffer stop tiles (I played a bit with randomness here).
[
]railroad bridges (of two types: concrete and metal grates)
[*]road/railroad crossings. Near cities they also have sidewalks[/ul]

Only dual railroads so far.

I took some screenshots to show the tiles in action. I have used the debug menu to place the map tiles in a meaningful way. I leave the task of tweaking the map generator to build entire railroads from these tiles to others.
Straight line and two curves:

A railroad bridge with concrete:

A railroad bridge with metal grates:

A buffer stop:

More buffer stops:

Railroad crossing in the wild:

Railroad crossing in near city:

Don’t get too exited about the last screenshot. That vehicle is just an ordinary car. It’s basically just a leftover before I changed the map. For now there are no spawns whatsoever on railroad tiles. If you looked closely, you see a minor problem with the curves. There is a part where two rubbles are next to each other. This is slightly unsymmetric. I think it could be fixed but I did not want to think about a solution so far. Except from that, I think those few tiles alrea

Personally I think this is just the beginning. The railroad tracks still could be improved. There are no switches whatsoever, not even junctions. You can basically only draw simple lines with these tiles.

But I hope this proof-of-concept should be more than enough for inclusion into the main game. I just do not have any clue how I could achieve this. Nor do I know where I should drop the changes to the source code. I am pretty new in programming for open source projects, so please forgive me. I would appreciate a bit help.

PS: Could a mod please move this thread to the “Lab” forum? This topic is clearly not a simple suggestion anymore. :slight_smile:

They all look really nice. I would say don’t worry about the the curves being symmetric; you’ll drive yourself mad trying to fix things like that, for little to no gain in the end.

What if you just do it as a straight diagonal rather then attempting to create a “curve”? So your corners would look something like this:

.X.....X. .X.....X.. .X......XX .X........ .X........ .X........ .X....... .X...... .XXXXXX ......

I have no real comment other than that this looks fantastic!! I’d really not worry about complete accuracy or lining everything up perfectly - as vache says, it’ll be very little gain for so much work.

If it ever becomes possible to merge these with Z-levels it’ll be awesome. Having these dip into a “cave” like opening that takes you into the subway system would be good. Oh, and Elevated train tracks would be nice.

A pull request is out here:

New!
I added crossbucks and railroad crossing signals. You find them only at railway crossings.

These tracks look huge. Cars are 6 tiles long and the tracks are 7 tiles wide!

Perhaps shrink it a little, and you’d be golden.
Me likey.

Okay, you have a good point here about the gauge. I think a good way to find the ideal track gauge is to compare it with hypothetical wagon designs.
I have experimented a bit with hypothetical passenger wagons on different gauges, namely 5, 4 and 3.

Key:
“-”: wall (of wagon) or railroad tie
“x”: railroad track
“+”: door
“H”: walkway
“#”: seat
“|” and “_”: wall
“^” rubble
“.” ground

A track gauge of 5 as I use currently seems indeed to be very broad.
This would allow for a wagon with 3 seats left and 3 seats right and a walkway which is 1 tile broad. This is a little bit extreme. Do such wagons exist?

..-x-----x-............. ..^x^^^^^x-............. ..-x-----x-............. .._________............ ..|###H###|............. ..|HHHHHHH|............. ..|###H###|............. ..|###H###|............. ..|HHHHHHH|............. ..|###H###|............. ..|---+---|............. ..+HHHHHHH+............. ..+HHHHHHH+............. ..|---+---|............. ..|###H###|............. ..|HHHHHHH|............. ..|###H###|.............
Note the entire railroad has to be covered so the (hypothetical) passengers can enter the train; otherwise they would have to cross a part of the railroad which is not a good idea. :wink:

With a gauge of 4, you can have 2 seats left and 2 seats right and a walkway of width 2:

..-x----x-.............
..^x^^^^x-.............
..-x----x-.............
..________.............
..|##HH##|.............
..|HHHHHH|.............
..|##HH##|.............
..|##HH##|.............
..|HHHHHH|.............
..|##HH##|.............
..|--++--|.............
..+HHHHHH+.............
..+HHHHHH+.............
..|--++--|.............
..|##HH##|.............
..|HHHHHH|.............
..|##HH##|.............

Another design would certainly be possible, for example 3+2 seats and an one-tile walkway. But I don’t like to break the symmetry.

A gauge of 3 allows 2 seats left and 2 seats right and a 1 tile broad walkway:

...-x---x-.............
...^x^^^x-.............
...-x---x-.............
..._______.............
...|##H##|.............
...|HHHHH|.............
...|##H##|.............
...|##H##|.............
...|HHHHH|.............
...|##H##|.............
...|--+--|.............
...+HHHHH+.............
...+HHHHH+.............
...|--+--|.............
...|##H##|.............
...|HHHHH|.............
...|##H##|.............

For me, the 3-tile gauge rail seems ideal to me as this allows for a wagon design I am used to in my daily life, so it seems the most sensible track gauge. However, I do not live in the U.S. and I have no clue about how passenger wagons are designed here. If you can give me some hints, please do so.
However I still live in a place where the standard gauge is the norm; I heard this gauge is also used (for the most part) in the U.S. So I think the 3-gauge design is the best choice.

I will wait for further input from you before proceeding.

too wide. one tile ~ 2 meters (6.5 feets)

I personally consider that the railroad must be just wide enough for a typical truck to fit on it.

A typical truck in Cataclysm - i.e. a Flatbed - is five tiles wide, meaning that a five-wide railroad - gauge 3 - is perfectly sized. Not so huge as to be unrealistically large, and not so narrow as to prevent an efficient traincar design from being used.

Seconding the 3 gauge. Closest to a real train track, and more selfishly, helps keep my dream of storing a car in a train base a reality.