Page 1 of 6

Tramroads for OTTD

Posted: 10 Feb 2007 15:48
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)?

Posted: 10 Feb 2007 18:28
by StopRightThere
So you're the secret ninja doing the trams in OTTD stuff? (this is a very old/obscure joke)
Good luck! :)

Posted: 10 Feb 2007 19:01
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...

Re: Tramroads for OTTD

Posted: 10 Feb 2007 19:09
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. :)

Posted: 10 Feb 2007 22:13
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 ;)

Posted: 10 Feb 2007 22:24
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.

Posted: 10 Feb 2007 22:45
by Valance
No problem :)

But be careful, there is a lot of trashcode in^^

Posted: 10 Feb 2007 23:15
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.

Posted: 10 Feb 2007 23:33
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 :)

Posted: 11 Feb 2007 00:16
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.

Posted: 11 Feb 2007 00:30
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 :)

Posted: 11 Feb 2007 01:32
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.

Posted: 11 Feb 2007 02:51
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.

Posted: 11 Feb 2007 13:15
by Digitalfox
Nice work Valance..

I wanted to try this in openttd for a long time :)

Posted: 11 Feb 2007 18:11
by Born Acorn
It seems I stand corrected! (although it isn't 1897 anymore) :p

Posted: 11 Feb 2007 23:35
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)

Posted: 12 Feb 2007 09:50
by Celestar
Do we have some diff for this?

Celestar

Posted: 12 Feb 2007 11:12
by Brianetta
Standard gauge look snice. Now, if we could just get mainline trains running on them...

Posted: 12 Feb 2007 13:20
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

Posted: 12 Feb 2007 13:25
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?