Patch: Diagonal level crossings

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

User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Patch: Diagonal level crossings

Post by Maedhros »

Hi everyone,

This is a patch to add diagonal level crossing support to OpenTTD. This is still a work-in-progress - although it works well, there aren't any graphics for it yet, so level crossings still appear to be perpendicular to the road, leaving trains to float over them. If there are any artists out there who'd be interested in this, I'd love to hear from you. :)

Something else I'm looking to fix is activating the lights on the other half of the crossing when the first are activated, and some other cleanups like allowing road vehicles to stop on the tile but before the level crossing.

Edit^4: It's pretty much complete now - it does everything I want it to, although the code could probably do with some cleaning up.

WARNING: Adding the patch option now without bumping the savegame version breaks any savegames already made with this savegame version.

If you've got any suggestions for how to do any of that, or feedback on the patch, please post it here. :)
Attachments
diagonal_crossings-miniin.diff
Patch against SVN MiniIN r5838.
(19.85 KiB) Downloaded 779 times
diagonal_crossings.diff
Patch against SVN trunk r5911.
(26.15 KiB) Downloaded 956 times
ncrossingsw.grf
GRF file for the new crossing graphics.
(7.53 KiB) Downloaded 1617 times
Last edited by Maedhros on 16 Aug 2007 09:30, edited 12 times in total.
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Diagonal crosings

Post by maquinista »

¡Thanks! It must be a great patch.
Can you put a preview image with the normal crossing?

There is a topic about diagonal crossings in TTD Patch:
http://www.tt-forums.net/viewtopic.php?t=26385
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post by Maedhros »

Ok, here's a preview. I warned you it looked strange. :lol:
Attachments
Preview of diagonal level crossings.
Preview of diagonal level crossings.
Nendinghattan Transport, 17th Mar 1991.png (180.32 KiB) Viewed 3704 times
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Thanks

Post by maquinista »

Thanks. I like it.
It will be needed four new graphics (with two tiles) for the crossings:

Code: Select all

 \                   / Road
===\===============/== Train
     \           /
       \       /
And the same in vertical.
Last edited by maquinista on 02 Aug 2006 22:53, edited 1 time in total.
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
iNVERTED
Route Supervisor
Route Supervisor
Posts: 387
Joined: 24 Apr 2005 21:21
Location: Torquay, England
Contact:

Post by iNVERTED »

And we need eight sprites per railway type, making 24.

And then we need to go ask everyone who made roadsets to make the extra 24 sprites for their roadsets.

And then we need to go ask everyone who made replacement railway types to make the extra 8*howevermanyroadsetsthereare sprites for their railway types.

...

See the problem with that?

Anyway, TTD has seperate sprites for the railway, monorail and maglev tracks by themselves. It uses these when drawing junction tiles - it draws 2 sprites on 1 tile. If we could utilize the same method for drawing your diagonal road crossings (and, in fact, ordinary road crossings too), we certainly wouldn't have to worry about other roadsets or tracksets. ;)
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

iNVERTED wrote:And we need eight sprites per railway type, making 24.

And then we need to go ask everyone who made roadsets to make the extra 24 sprites for their roadsets.

And then we need to go ask everyone who made replacement railway types to make the extra 8*howevermanyroadsetsthereare sprites for their railway types.

...
WTF?

24 new pictures and enough. Who wants to have that feature, too, can add diagonal rail crossing pictures to his grfset. If not the default ones are used. IMO
iNVERTED
Route Supervisor
Route Supervisor
Posts: 387
Joined: 24 Apr 2005 21:21
Location: Torquay, England
Contact:

Post by iNVERTED »

I was joking about the asking everyone bit. :P
User avatar
StopRightThere
Chief Executive
Chief Executive
Posts: 761
Joined: 18 Dec 2005 20:10
Location: United Kingdom

Post by StopRightThere »

OMG! This patch is awesome!
Bye Bye OpenBVE :(
Official TT-Hot young ginger Doctor Who assistant FanClub
Formerly known as AdditionalData
Ar4i
Traffic Manager
Traffic Manager
Posts: 153
Joined: 24 Jul 2006 10:40

Post by Ar4i »

What about diagonal bridges? I think those would be much more useful, as the lack of diagonal bridges often generates pretty ugly crossings... Not to mention that road crossing RR is far from safe.
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

It's a option

Post by maquinista »

Ar4i wrote:What about diagonal bridges? I think those would be much more useful, as the lack of diagonal bridges often generates pretty ugly crossings... Not to mention that road crossing RR is far from safe.
This is a option. If you don't like it, you don't need build it.
Magic bridges are other interesting option. They isn't incompatibles with diagonal crossings.
Two options are better than only one option.
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

maquinista wrote:
Ar4i wrote:What about diagonal bridges? I think those would be much more useful, as the lack of diagonal bridges often generates pretty ugly crossings... Not to mention that road crossing RR is far from safe.
This is a option. If you don't like it, you don't need build it.
That's not what he said. He only finds diagonal bridges more useful then diagonal road crossings. Both are useful IMO.
But i think the diagonal bridges have the problem with saving the information in the map array. On some tiles you need to save informations of 2 bridges. I don't know what all is saved in the map array of every bridge, but it is saved there.
maquinista
Tycoon
Tycoon
Posts: 1828
Joined: 10 Jul 2006 00:43
Location: Spain

Ok

Post by maquinista »

gigajum wrote:
maquinista wrote:
Ar4i wrote:What about diagonal bridges? I think those would be much more useful, as the lack of diagonal bridges often generates pretty ugly crossings... Not to mention that road crossing RR is far from safe.
This is a option. If you don't like it, you don't need build it.
That's not what he said. He only finds diagonal bridges more useful then diagonal road crossings. Both are useful IMO.
But i think the diagonal bridges have the problem with saving the information in the map array. On some tiles you need to save informations of 2 bridges. I don't know what all is saved in the map array of every bridge, but it is saved there.
Yes, I have understand it.
The three options (diagonal crossings, diagonal bridges and magic brigdes) are good.
Sorry if my english is too poor, I want learn it, but it isn't too easy.[/list][/size]
User avatar
Ben_Robbins_
Tycoon
Tycoon
Posts: 1234
Joined: 20 Nov 2005 01:56
Location: Abu Dhabi, UAE

Post by Ben_Robbins_ »

24 didnt sound too bad so I started, but kept thinking of more...After almost 3 hours Ive decided to stop with just the railway ones done. Theres 308 different tiles here that i could think of. This would be 1/4 of the total amount (just counting the rail/electric/mono/mag)
Attachments
diagonal crossings4.PNG
(178.09 KiB) Downloaded 1811 times
Ben
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post by Maedhros »

Woah. :shock: Those are impressive, but 308 per landscape, per road type is insane. I guess there are probably ways to overlay sprites on top of each other, so I'll have to start looking at the newgrf specs and seeing how that could be done.

I've updated the patches by the way - they now activate the other half of a diagonal level crossing at the same time as the first half. Sounds simple, but the patch is now more than twice the size. :roll:
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

Ben_Robbins_ wrote:24 didnt sound too bad so I started, but kept thinking of more...After almost 3 hours Ive decided to stop with just the railway ones done. Theres 308 different tiles here that i could think of. This would be 1/4 of the total amount (just counting the rail/electric/mono/mag)
WOW :shock:

That's impressive. Is there no way of automation?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Ben_Robbins_ wrote:This would be 1/4 of the total amount (just counting the rail/electric/mono/mag)
One third. Electric uses the exact same sprites as regular; it just adds the catenary sprites.

Some of the lights in there look like they're facing along the tracks, not along the road. The last two in the second row on the left side, for example.

Maedhros wrote:Those are impressive, but 308 per landscape, per road type is insane.
No. That's 308 per road type per track type -- 924 per road type, unless you pull overlays. Ben's got all the landscapes in there
Maedhros wrote:I guess there are probably ways to overlay sprites on top of each other, so I'll have to start looking at the newgrf specs and seeing how that could be done.
You won't find that in the newgrf specs.

I might suggest:
Four gate/light sprites per base sprite: one left and right gate/light for open/clear and another for closed/occupied. One might work, but I'm worried that there might be bounding-box fun if you do that.
Then duplicate this for the other direction. (N/S vs E/W)

Then just grab the appropriate sprites out of trg?r.grg, and past them on top of the road base. Except that this will work poorly for maglev.
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
Brianetta
Tycoon
Tycoon
Posts: 2566
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

Also, there's the small point that the flashing lights are done by palette cycling, so you only actually need two thirds as many (lights off, lights on).
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
User avatar
Ben_Robbins_
Tycoon
Tycoon
Posts: 1234
Joined: 20 Nov 2005 01:56
Location: Abu Dhabi, UAE

Post by Ben_Robbins_ »

Dalestan: I see what you mean, but i think when the lights alternate to the other red dot, the direction the signal faces should be clearer. If not, they can be tweaked when they can be seen better in a scenario.

Gigajum: Dunno what you mean by automation really...

Might try making some more later, cause this is a cool feature I recon, but I'll wait a bit, cause theres other graphics to make at the moment. Feal free to do what ever with those tiles if anyone needs them for anything though.

(oh yeah, i didnt do the mars scape...dang..)

<edit> brianetta: ''palette cycling''? theres 3 at the moment, on left, on right and off.
Ben
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

Ben_Robbins_ wrote:Gigajum: Dunno what you mean by automation really...
Let the computer do the work for you, instead of doing it yourself.
You have 11 different ground pictures, 4 different rail types, 3 pictures for the crossing lights, and so on. Isn't it possible to tell the computer how he has to mix the pictures to generate alle the ~1000 different tile pictures which are needed,
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

Ben_Robbins_ wrote:Dalestan: I see what you mean, but i think when the lights alternate to the other red dot, the direction the signal faces should be clearer. If not, they can be tweaked when they can be seen better in a scenario.

Gigajum: Dunno what you mean by automation really...

Might try making some more later, cause this is a cool feature I recon, but I'll wait a bit, cause theres other graphics to make at the moment. Feal free to do what ever with those tiles if anyone needs them for anything though.

(oh yeah, i didnt do the mars scape...dang..)

<edit> brianetta: ''palette cycling''? theres 3 at the moment, on left, on right and off.
the game animates the flashing crossing lights by 'palette cycling'. it swaps some colors in game (how it actually works isn't that interesting)
It means that you only need 2 signal states, On and Off. See the original ttd sprites as an example of how it works (you need 2 specific palette index colors)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 32 guests