Tramroads for OTTD

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
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Tramroads for OTTD

Post by Valance »

I'm experimenting with getting tramroads (like they are in ttdpatch) into ottd (I'm able to build tramroads already). But how do I add 112 sprites without overwriting existing ones?

Just now I'm doing it like this:

In sprites.h:

Code: Select all

	SPR_TRAMROAD_BASE = SPR_ROADSTOP_BASE + 8, // The sprites used for drive-through road stops
	SPR_TRAMROAD_ROAD = SPR_TRAMROAD_BASE + 4,
	SPR_TRAMROAD_TRAM = SPR_TRAMROAD_BASE + 27,
In gfxinit.cpp:

Code: Select all

	assert(load_index == SPR_ROADSTOP_BASE);
	load_index += LoadGrfFile("roadstops.grf", load_index, i++);

	assert(load_index == SPR_TRAMROAD_BASE);
	load_index += LoadGrfFile("tramroads.grf", load_index, i++);
I thought doing it like the sprites for drive-through-roadstops were added should work, but now it seems, I've overwritten some gui sprites :( Would be even better, if someone could also tell me, how to add them to the same spriteid like in ttdpatch (to be compatible to grf's changing them).

P.S.: If I'm able to get the whole tram stuff working, are I allowed to use the sprites from ttdpatch and release them as a grf for ottd (I don't want to add all the sprites from ttdpbase, just the ones for tramroads)?
Attachments
Nedham Transport, 30. Jan 1950.png
Nedham Transport, 30. Jan 1950.png (53.73 KiB) Viewed 18143 times
Spritebug :(
Spritebug :(
tramroad_spritebug.png (22.55 KiB) Viewed 18146 times
User avatar
StopRightThere
Chief Executive
Chief Executive
Posts: 761
Joined: 18 Dec 2005 20:10
Location: United Kingdom

Post by StopRightThere »

So you're the secret ninja doing the trams in OTTD stuff? (this is a very old/obscure joke)
Good luck! :)
Bye Bye OpenBVE :(
Official TT-Hot young ginger Doctor Who assistant FanClub
Formerly known as AdditionalData
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Post by fabca2 »

such a good news !...
I whish you good luck,
some of us are waiting for people like you for years ;)
now, lets hope you will get help from devs or else...
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Re: Tramroads for OTTD

Post by mart3p »

Valance wrote:I'm experimenting with getting tramroads (like they are in ttdpatch) into ottd (I'm able to build tramroads already). But how do I add 112 sprites without overwriting existing ones?
I’ve no idea why you're having this problem, your code looks ok.
Valance wrote:( Would be even better, if someone could also tell me, how to add them to the same spriteid like in ttdpatch (to be compatible to grf's changing them).
TTDPatch tram track graphics are changed using Action 5 feature type B. This is not currently implemented in OpenTTD so you would need to add it. Look at how Action 5 is implemented for other features (like signals or elrails) (newgrf.cpp - line 2160) You will see that OpenTTD‘s sprite ids don‘t need to match those of TTDPatch, the action 5 code does the right thing.
Valance wrote:P.S.: If I'm able to get the whole tram stuff working, are I allowed to use the sprites from ttdpatch and release them as a grf for ottd (I don't want to add all the sprites from ttdpbase, just the ones for tramroads)?
You will need to find out who the author is and ask their permission.

Anyway good luck with this and if you want to understand gamezguy’s joke look here. :)
Image
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Post by Valance »

It's not the first time I had problems with missing sprites. Some days ago I tried to user your drive through roadstops patch with roadmarkers patch, the same problem (ottd crashed and told me it's missing sprite #5981).

Today (after source update from svn) it didn't crash anymore, just showing gfx glitches. I enabled debug messages and got this:

Code: Select all

dbg: [sprite] Tried to load non-existing sprite #5981. Probable cause: Wrong/missing NewGRFs
dbg: [sprite] Tried to load non-existing sprite #5981. Probable cause: Wrong/missing NewGRFs
dbg: [sprite] Tried to load non-existing sprite #5981. Probable cause: Wrong/missing NewGRFs
dbg: [sprite] Tried to load non-existing sprite #5981. Probable cause: Wrong/missing NewGRFs
dbg: [sprite] Tried to load non-existing sprite #5981. Probable cause: Wrong/missing NewGRFs
Some lines earlier ottd told me:

Code: Select all

dbg: [sprite] Loading sprite set 0
dbg: [sprite] Reading indexed grf-file 'TRG1R.GRF'
dbg: [sprite] Reading grf-file 'TRGIR.GRF'
dbg: [sprite] Currently 4896 sprites are loaded
dbg: [sprite] Reading grf-file 'nsignalsw.grf'
dbg: [sprite] Currently 5382 sprites are loaded
dbg: [sprite] Reading grf-file 'canalsw.grf'
dbg: [sprite] Currently 5452 sprites are loaded
dbg: [sprite] Reading indexed grf-file 'trkfoundw.grf'
dbg: [sprite] Reading grf-file 'autorail.grf'
dbg: [sprite] Currently 5585 sprites are loaded
dbg: [sprite] Reading grf-file 'elrailsw.grf'
dbg: [sprite] Currently 5638 sprites are loaded
dbg: [sprite] Reading grf-file '2ccmap.grf'
dbg: [sprite] Currently 5894 sprites are loaded
dbg: [sprite] Reading indexed grf-file 'openttd.grf'
dbg: [sprite] Reading grf-file 'airports.grf'
dbg: [sprite] Currently 6025 sprites are loaded
dbg: [sprite] Reading grf-file 'roadstops.grf'
dbg: [sprite] Currently 6033 sprites are loaded
dbg: [sprite] Reading grf-file 'tramroads.grf'
dbg: [sprite] Currently 6146 sprites are loaded
loading sprites was successful. How can loading more sprites beginning at index 6033 make the ones at 5981 - 5983 disappear?

Thanks, the info about action 5 feat. B helped a lot :) Shouldn't that complicated to code it.

Hehe, I see, much to do for me ;)
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Post by Rubidium »

Do you care to show a diff, as I can start guessing what might be wrong, but it's probably easier to fix when someone with some knowledge about the SpriteIDs takes a look at it.
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Post by Valance »

No problem :)

But be careful, there is a lot of trashcode in^^
Attachments
trams-1.diff
(71.06 KiB) Downloaded 623 times
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Post by Rubidium »

Compare lines 167-171 with 194-195 in your diff (there might be more instances of this, haven't looked in depth at it). Your editor did probably not understand that the file was UTF-8 encoded and destroyed all Unicode characters in it, making a big mess of the whole file.
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Post by Valance »

Hm :( I really begin to hate kwrite... First german umlauts, and now this.

Thanks for finding it :) Should switch to vim as editor^^

Edit: Got the trams to drive on their shiny new tramroads :)
Attachments
Nundinghall Transport, 29. Mär 2000.png
Nundinghall Transport, 29. Mär 2000.png (80.63 KiB) Viewed 17912 times
Archonix
Chief Executive
Chief Executive
Posts: 733
Joined: 01 May 2003 17:29
Location: Manchester, UK
Contact:

Post by Archonix »

Kwrite can be changed to edit your file in utf8, you know. GOi to settings -> configure editor, and then in load/save switch the format to whatever you want. Easy as pie. :)

Anyway, for programming you should probably be using Kate at the very least, and you might want to consider getting a decent IDE. The two I use are Kdevelop and Eclipse.
Brignell’s law of consensus: At times of high scientific controversy, the consensus is always wrong.
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Post by Valance »

Hehe, it's already configured for loading/saving with utf8, but as we've seen, it didn't help :( Could be another wrong configuration by me, but I haven't found the wrong setting some month ago, and I think, I won't go searching again now.

The same problem will occur in Kate and KDevelop (tried it already some month ago). But perhaps, I'll give Eclipse a try, but for now, vim / gvim seems to work fine :)
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

Ooh, good work, I've been awaiting these in OpenTTD for quite a whiles.

I've never heard the term "tramroad" used before. It sounds rather strange, seeing as they are basically rail tracks and not roads.
Image
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Post by PikkaBird »

Valance,

You can get a grf with only (standard gauge) tram tracks in it here.

I don't have an up-to-date standalone grf of the original tramtracks in ttdpbase.grf, but there's no reason why I couldn't make one.
User avatar
Digitalfox
Chief Executive
Chief Executive
Posts: 710
Joined: 28 Oct 2004 04:42
Location: Catch the Fox if you can...

Post by Digitalfox »

Nice work Valance..

I wanted to try this in openttd for a long time :)
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

It seems I stand corrected! (although it isn't 1897 anymore) :p
Image
User avatar
Valance
Engineer
Engineer
Posts: 28
Joined: 06 Feb 2007 07:17

Post by Valance »

I've never heard the term "tramroad" used before. It sounds rather strange, seeing as they are basically rail tracks and not roads.
Oh, I thought I invented this word ;) No, it happend while coding ... I began to use "tramroad" as "road for trams" (as I handle them like roads). I will change it later.
You can get a grf with only (standard gauge) tram tracks in it here.

I don't have an up-to-date standalone grf of the original tramtracks in ttdpbase.grf, but there's no reason why I couldn't make one.
I've created already a standalone grf from the ttdpbase ones to work with. (I'm no artist^^) But I like your standard gauge ones more, especially the (lightweight, I attached a screenshot to see what I mean) wires.

Today I added tram depots (aren't working yet), had some nice fights against a lot of funny bugs I coded *lol* and got drawing of wires and poles halfway-working (wasn't able yet to find a way to draw the ones for slopes, as I haven't found out how their sprites are arranged)
Attachments
Brennpool Bridge Transport, 12. Mär 2001.png
Brennpool Bridge Transport, 12. Mär 2001.png (83.15 KiB) Viewed 17532 times
Brennpool Bridge Transport, 7. Apr 2001.png
Brennpool Bridge Transport, 7. Apr 2001.png (93.69 KiB) Viewed 17544 times
User avatar
Celestar
Director
Director
Posts: 574
Joined: 02 Jul 2004 10:56
Contact:

Post by Celestar »

Do we have some diff for this?

Celestar
User avatar
Brianetta
Tycoon
Tycoon
Posts: 2567
Joined: 15 Oct 2003 22:00
Location: Jarrow, UK
Contact:

Post by Brianetta »

Standard gauge look snice. Now, if we could just get mainline trains running on them...
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
N8king
Engineer
Engineer
Posts: 27
Joined: 11 Nov 2006 14:49
Location: Graz/Austria

Post by N8king »

Hello Valance!

Its nice work you did for the implementation of tramroads in OTTD and I like it very much. Also I think it was "höchste Eisenbahn" to enclude this stuff.
Now to the wires and poles on your to pics:
1. Picture the wires looking good, I would prefere them.
2. Picture the poles appear very often and look very shiny, so thats looks ugly IMO.
As in cities with tramroads all catanery is fixed on the buildings walls they passes, there are only a few poles when there is needet. So I think it would be better the poles would disappear when buildings are near the tramroad.

N8king
Connum
Engineer
Engineer
Posts: 127
Joined: 25 Dec 2006 17:05

Post by Connum »

Wow, that's great! (Wirklich gute Arbeit, Valance!)
I'm looking forward to that feature!

How will you prevent crashes between trams and buses? Having signals all over the track will look bad and be quite annoying... Is it possible to let busses and trams just take care on each other, like it is in reallife when busses and trams are on the same track?
English is not my native language, so please excuse me if I sometimes might appear a bit harsh or if I make a spelling or grammar mistake!
Locked

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 22 guests