Page 1 of 3

Road Types NewGRF Specification

Posted: 26 Aug 2011 14:40
by Leanden
I have had a rather lengthy idea which i will slowly develop over the next few days with added concept art and ideas.

Basically it would require two main changes that i can see:

1) A change to how the pathfinder treats multi-lane roads
2) A modification to the newgrf spec to add new road types

I understand that this is something people have spoke about for a while, but noone has ever really seemed willing to dive into it and actually give it some proper thought.

Now obviously by default, this wouldnt effect the game, the changes would only be implemented through NewGRFs (except that vehicles would use both lanes of one way roads correctly). The idea is that through a newgrf, you can specify several road types, and then by linking together half a tile of one road type and half a tile of another road type, you get a special transitional piece.

Like NuTracks, you would be able to specify speed, and additionally how many lanes the road has. A further development of this could be to eventually have special road tiles with things like roundabouts and junction turnoffs. I will create some concept art to demonstrate this soon.

Re: NuRoads

Posted: 26 Aug 2011 15:01
by kotssmurf
:bow:

Re: NuRoads

Posted: 26 Aug 2011 15:20
by FooBar
oh, roadtypes was given a proper thought while petern developed railtypes. I'm pretty sure you still can find trace of that in the openttd wiki.

But yes, I think roadtypes is a good idea. It 'just' needs 'someone' to implement it :)

Re: NuRoads

Posted: 26 Aug 2011 15:47
by FooBar
Oh, I looked it up for you now that I'm on my computer (easier with the copy/paste and such): http://wiki.openttd.org/Peter1138/Roadtypes

I think the best approach here is to design a NewGRF specification like railtypes but then for roadtypes. If that can be made solid, a developer or patchwright might get interested and actually implement this. And it really helps if you can provide a NewGRF that actually is coded according to that spec for testing purposes.


I'd leave your idea about the "halftile linking" out of the initial spec and just do it like railtypes: stop one type and continue with the other on the next. Overlapping could look better, but it's a bit of a bear trap to implement. First of all the original road and tram track set doesn't have these overlap graphics. Then when it comes to drawing the overlap, two different sets end up providing two different sprites: who should be drawn on top of who? And how would this work at junctions where a secondary road of one type is attached to a main road of the other type? Just drawing the border at the tile edge is much less complicated, which eventually gives this a higher chance to be implemented


If you want, I may be able to assist on writing this specification (of if you wait long enough I might write it myself at some point).

Re: NuRoads

Posted: 26 Aug 2011 16:30
by Leanden
I thought about having the tile draw up to the edge, but think for example if you have a 3-lane motorway road then turn immediately into a 2-way road with no conversion graphics in between, It'd look pretty bad. There would have to be some way of having the roads change from one type to the other without them just being next to each other.

Also what about improving the pathfinder to allow for better lane utilisation? I hear this is buried deep in the code of Openttd so it'd be difficult to manipulate.

EDIT: Can't seem to find the railtype specification, just loads of information about labels, variables and callbacks.

Re: NuRoads

Posted: 26 Aug 2011 17:53
by FooBar
Ah, I didn't realise that you were also thinking three lane roads. Also that is something that you probably should forget, at least initially. It will need a tremendous amount of work to make three lane roads possible. Roadtypes is basically about changing the graphics and applying a speed limit; not really that much different to how the game works now. Three lane roads will apart from this also involve completely overhauling the pathfinder and road vehicle drawing code; a great deal of work which is unlikely to be accepted as a single patch (unless an OpenTTD Dev decides to make it).
So while I'm absolutely not against three lane roads, I think it's best for now to limit yourself to not wanting all at once :)


Improving the pathfinder to better work with one-way roads is certainly possible (I don't know how, but I believe I've seen an initial patch for that a while ago). Basically the only aspect needed here is to allow overtaking for articulated vehicles. There's not much advantage in making real two lane traffic, as you'll always end up with a huge bottleneck where both lanes need to merge into one. So overtaking for all road vehicles would be a big win here; two lane traffic will add very little benefit and most likely will only make it worse.


As for the railtype spec, it's a bit hidden on the Action3 page: http://newgrf-specs.tt-wiki.net/wiki/Action3#cargo-type, combined with the properties: http://newgrf-specs.tt-wiki.net/wiki/Action0/Railtypes, the sprite definition: http://newgrf-specs.tt-wiki.net/wiki/Action2/Single_Set the variables: http://newgrf-specs.tt-wiki.net/wiki/Va ... /Railtypes, a bit on random bits: http://newgrf-specs.tt-wiki.net/wiki/Ra ... Rail_types. There are no railtype callbacks. And don't forget the railtype translation table: http://newgrf-specs.tt-wiki.net/wiki/Ac ... e_.2812.29

Basically all these could be used as a basis for roadtypes. If you stay as close to the railtype specs, nothing can go wrong really. If you want to attempt something, I recommend you to include possibilities for diagonal roads and the possibility for custom catanery per roadtype. Also don't forget that tram tracks are a roadtype and that the specs need to account for these too (which will make it a bit more complicated than the railtype specs).

Re: NuRoads

Posted: 26 Aug 2011 18:12
by Leanden
Ye because obviously you have to disable overtaking for tram track vehicles.

Is there a possibility as well to maybe make it so that certain road types dont cause collisions with other railtypes, this way you could perhaps implement subways as a road type which is almost invisible where the vehicles done collide with road vehicles?

Re: NuRoads

Posted: 26 Aug 2011 19:30
by FooBar
Leanden wrote:Ye because obviously you have to disable overtaking for tram track vehicles.
Certainly. And it might be good to have this optional for other roadtypes as well. Think trolleybuses.

I think somehow a distinction must be made between basic roadtypes and overlay roadtypes. The basic roadtypes are like normal road and they can have no catanery. They cannot be built on top of each other. The overlay roadtypes are like tramways and can (but must not) have catanery. These overlay types can be built separately, on top of basic types but not on top of each other. However they can cross each other perpendicular (like how tramway crosses rail).

Leanden wrote:Is there a possibility as well to maybe make it so that certain road types dont cause collisions with other railtypes, this way you could perhaps implement subways as a road type which is almost invisible where the vehicles done collide with road vehicles?
Well, in theory everything is possible. Not having collisions with rail vehicles would be easy (but weird). I might see a benefit in "vehicles of this roadtype also crash the train when both collide".
No collisions with road vehicles of a different roadtype when driving in the same direction would fall in the category of changing how road vehicles work. Possible, but not a lot will be interested in making this.

Re: NuRoads

Posted: 26 Aug 2011 19:39
by Leanden
Well the only thing i was thinking of is that lots of people have requested subways, this might be one way of implementing it by having it as a underlay road type which doesnt interfere with road traffic.

This wouldnt neccesarily come as standard, but it would be in the newgrf spec so that people could code subways that way if they wanted too. Also think of suspended monorail ;)

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 20:05
by Terkhen
I think that it should be better to fix the overtaking mess before doing roadtypes.

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 20:35
by Leanden
But noone can ever be bothered with fixing the pathfinder, doing road types would be an incentive to get the pathfinder code fixed. With this and variable cargo aging, RVs are becoming feasible as transport once again.

Re: NuRoads

Posted: 26 Aug 2011 20:43
by nicfer
Can I ask some off-topic-ish? Since diagonal roads are unlikely to be added, why not modify tracks to have a specific value that makes RVs running over them not slow down if they're going 'diagonally', that means they're turning left and right constantly, while only turning right or doing right-left-right slows them similarly to how trains are handled (the longer the curve, lesser the slowdown).

And more on topic, will newroads API support disabling town growth near tagged road types (like 'highways')?

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 20:49
by Leanden
Diagonal roads is something we are thinking off. As for town growth, there is no reason this couldnt be some sort of flag that prevents town growth on that type of road. I believe that for example towns won't grow on tram tracks.

Re: NuRoads

Posted: 26 Aug 2011 20:58
by Supercheese
Leanden wrote:Well the only thing i was thinking of is that lots of people have requested subways, this might be one way of implementing it by having it as a underlay road type which doesnt interfere with road traffic.

This wouldnt neccesarily come as standard, but it would be in the newgrf spec so that people could code subways that way if they wanted too. Also think of suspended monorail ;)
That does sound pretty cool to me. The graphics for subway vehicles would be pretty simple too -- just a shadow or outline since it's all underground! :P

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:05
by Level Crossing
But if subways would be roadtypes, then that means that the land above the subways would need to be cleared anyway, defeating the objective.

The alternative is making a new type of tram tracks: with the same graphics as normal roads but vehicles underground. The drawback would be that subways could only be under streets.

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:07
by Supercheese
Level Crossing wrote:The alternative is making a new type of tram tracks: with the same graphics as normal roads but vehicles underground. The drawback would be that subways could only be under streets.
That's what I meant...

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:35
by Eddi
Level Crossing wrote:subways could only be under streets.
that is what 90% of all subways do anyway.

the problem with that concept is connection with "over ground" (light-) rail, e.g. in the outskirts of a city, or elevated rails.

also might want to make sure that tunnels cannot cross a subway.

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:42
by Supercheese
Eddi wrote:also might want to make sure that tunnels cannot cross a subway.
Eh, I think allowing tunnels to cross subways could be explained by asserting that "they build one tunnel above/below the other".

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:45
by Level Crossing
Supercheese wrote:
Eddi wrote:also might want to make sure that tunnels cannot cross a subway.
Eh, I think allowing tunnels to cross subways could be explained by asserting that "they build one tunnel above/below the other".
But then that contradicts the fact that tunnels in general cannot be built one above/below the other.

Re: Road Types NewGRF Specification

Posted: 26 Aug 2011 21:47
by Leanden
But in the game, you can build one tunnel above another, so why would you not be able to build tunnels under subways?