Have I missed something?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Have I missed something?

Post by Darker »

Hello. The only help and advice how to edit grf files was the GRFcodec dos app download. Okay, I have extracted one existing grf file to see whats hidden inside. I have obtained one very nice image messed up with textures (which killed my hope to edit GRF in msPaint and Irfan) and one .nfo file messed up with names and values.
Should I edit this in PSpad? I don't think so.
So, where is the app to get images separated and values human readable? I don't want too much from you, anyway.
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Have I missed something?

Post by planetmaker »

You did not miss anything except maybe the documentation on the NFO specs.

NewGRFs are a piece of software, not just a fancy collection of stats for the single vehicles; thus what you got is de-compiled code which is not very pretty. NFO files can be edited by any plain text editor, png or pcx files modified by any graphics programme which understands the concept of palettes.
Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: Have I missed something?

Post by Supercheese »

Attempting to make sense of a decompiled .grf is, unfortunately, not very easy IMO. It is entirely within the realm of possibility, however. The most helpful resource for that endeavor is the NewGRF specs wiki.

Creating a new grf from scratch, however, is easier thanks to NML. If the .grf you want to look at/edit is written in NML and hosted on, say, the OTTD Devzone, then things are even easier. Even if it is written in NFO, I reckon the authors' comments on their sources are much easier to deal with than raw decompiled code.
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5631
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Have I missed something?

Post by PikkaBird »

You've missed how to write a descriptive thread topic, for one thing. :roll:

If you want to create your own grfs, starting from a decompiled grf is not a good idea, because you'll just be faced with an uncommented block of code. It's a much better idea to start from scratch and from example code provided by experienced coders. If what you want to do is alter something in an existing grf, that's quite possible, but very hard unless you're an experienced grf author and know what you're looking for in that block of code.

I don't know what "messed up with textures" means, but I'm guessing you decompiled with the wrong palette.
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Have I missed something?

Post by Leanden »

I suspect he was probably missing a "-p 2" somewhere on the end of his command line.
Image
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

This is the post I have attempted to send yesterday, and which isn't so actual today.
So i have decompiled (decoded or what ever) the vactrain.grf, got the mentioned two files - image, and some plain-text crap.
What I can see:

Code: Select all

  209 * 34	 04 00 7F 01 FF 75 00 "VACT-0002 \"Airline Killer\"" 00
  210 * 35	 04 00 02 01 FF 75 00 "VACT-0002 \"Flugzeug-Killer\"" 00
Seems like multi language data. But I can't believe someone has written it like this...
I can only guess that the offset +4 (third number twin) represents language name, coz its different within languages. Where the author gor the correct value for the corresponding language?
This:

Code: Select all

  147 * 6	 01 00 02 FF 08 00
  148 sprites/vactrain.pcx 66 552 01 26 10 -5 -12
  149 sprites/vactrain.pcx 82 552 01 17 22 -14 -9
  150 sprites/vactrain.pcx 114 552 01 12 32 -16 -8
  151 sprites/vactrain.pcx 162 552 01 17 22 -6 -9
  152 sprites/vactrain.pcx 194 552 01 26 10 -5 -12
  153 sprites/vactrain.pcx 210 552 01 17 22 -14 -9
seems to represent pixel coordinates of image parts. I am farely sure this was generated with decoder and cold be genereted as varions files instead.
A have recoloured tunell (or whatever it was) to yellow, and did a pretty more changes, but it did'nt have any effect. Even if I hac deleted the original vactrain tar file, OpenTTD worked with vacum tube like nothing happened.
Where the data are really stored...?

And now the todays post:
I have tryed to use -p 2 parameter, but the result was same. I have uploaded the image with sprites.
Attachments
The sprites.
The sprites.
vactrain.jpg (48.2 KiB) Viewed 3515 times
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Have I missed something?

Post by planetmaker »

You should probably visit the vactrain topic, look where the author posted the source code and read that...

Shouldn't that be the first thing to do? Look for the proper source than trying to de-compile anything?
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Have I missed something?

Post by FooBar »

Darker wrote:But I can't believe someone has written it like this...
Someone has written it exactly like that. Maybe with some added comments, but writing it any other way will just plain not work (or use NML instead, but that will ultimately convert it to exactly that). What each line means is explained here: http://newgrf-specs.tt-wiki.net/wiki/Action4
Darker wrote:...seems to represent pixel coordinates of image parts.
Correct, and explained here: http://newgrf-specs.tt-wiki.net/wiki/RealSprites
The original source could very well have used multiple image files, but since this information is not stored in the grf (there's no need for the game to know that information), there's also no way for grfcodec to output the graphics into multiple files. How should it know what graphic to put in what file? Therefore it gives everything in one file and therefore it's far more useful to obtain the original source instead (but that may not always be available).

As for why your changes did not work:
You did encode the changes into a new grf file? You checked that the timestamp of the grf file indeed indicated it being a new version? And you made sure that the grf file is in one of OpenTTD's search paths?
I also noticed that the image you uploaded is a jpg image. Is this the one you made changes to? If so, you must know that grfcodec doesn't understand jpg images and that the NFO source still references the decoded pcx file. So you need to save the changes to this pcx file, maintaining it's palette, for the changes to be actually encoded back into a grf file.
User avatar
Leanden
Tycoon
Tycoon
Posts: 2613
Joined: 19 Mar 2009 19:25
Location: Kent

Re: Have I missed something?

Post by Leanden »

I can't honestly see anything wrong with the image you posted.
Image
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

planetmaker:
I haven't a clue that theres some "vactrain topic", so I'll search for it.
FooBar:
FooBar wrote:The original source could very well have used multiple image files [...]
Once it could create image from sprites (and gave them numbers), it cold export each sprite in diferent file (and give it a number as it did for sprites in large PCX) and this can be, thearotically, aditionall seting.
FooBar wrote:You did encode the changes into a new grf file?
What else you expected me to do?
FooBar wrote:You checked that the timestamp of the grf file indeed indicated it being a new version?
I did it now. The tar files timestamp is very sure later then the time I've downloaded the original graphic file.
FooBar wrote:And you made sure that the grf file is in one of OpenTTD's search paths?
And this is what?
FooBar wrote:I also noticed that the image you uploaded is a jpg image.
I've resized the original PCX to faster upload.

I didn't obtain any errors while encoding file back.
I didn't obtain eny errors when decoding it again.
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Have I missed something?

Post by Eddi »

Darker wrote:
FooBar wrote:The original source could very well have used multiple image files [...]
Once it could create image from sprites (and gave them numbers), it cold export each sprite in diferent file (and give it a number as it did for sprites in large PCX) and this can be, thearotically, aditionall seting.
it'd be more useful to create one file per spritegroup, not per sprite, though.
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

I didn't know sprites are grouped.
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Have I missed something?

Post by FooBar »

Darker wrote:tar
You don't really need to tar a grf. The timestamp of a tar doesn't say much really, as it could very well contain old files.
Darker wrote:And this is what? [search paths]
These are the directories where OpenTTD looks for grf files. The OpenTTD readme will tell you which these are for your operating system.
Darker wrote:What else you expected me to do?
I expect nothing. I'm just troubleshooting here ;)
Darker wrote:I've resized the original PCX to faster upload.
Ok, just checking to make sure you didn't save your edits to jpg.
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

FooBar wrote:You don't really need to tar a grf.
I just made it to look like i have copyed it. (from C:\Documents and Settings\user\Dokumenty\OpenTTD\content_download)
FooBar wrote:These are the directories where OpenTTD looks for grf files.
Ok then, but there is no from the downloaded GRFs... I want to replace Vac Train which is already instaled.

Now I'm gonna try to put the vactrain.grf into D:\hry\ttd\data and see if something happens.
EDIT:I've put it there and, thank you, it works. Now I only wondwr, why red pixels blink (i've put there few to see that it works)
EDIT2:Is there a way to update graphic without restarting game?
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Have I missed something?

Post by planetmaker »

use reload_newgrfs in the console
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Have I missed something?

Post by FooBar »

Darker wrote:Now I only wondwr, why red pixels blink
Most likely you have used the red that is part of the "red cycle". These are intended for the railway crossing lights, but blink in other places as well. See http://newgrf-specs.tt-wiki.net/wiki/Pa ... s#Palettes for details. There are more special colours in the palette that you normally shouldn't use.
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

planetmaker wrote:use reload_newgrfs in the console
Unfortunally it returned this:
OTTD console wrote:ERROR: command not found
Shouldn't I write something before the command?

FooBar:
Yes seems you are absolutelly right. I guessed something like this, thank you for the link. And is it OK when I create tracks which blinks? (what about CPU...?)
And why the company color didn't work for tracks? (I mean: Is it possible to differ tracks with colors some other way?)

And, if you use some good freeware editor (better than Irfan or MSpaint) please recomend it to me :)
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Have I missed something?

Post by planetmaker »

reload_newgrfs is only available when the newgrf developer tools are turned on.
User avatar
Darker
Engineer
Engineer
Posts: 56
Joined: 07 Aug 2011 14:32
Skype: zergdarker
Contact:

Re: Have I missed something?

Post by Darker »

planetmaker:
Thank you, works perfectly.

FooBar:
Thank you for GRF specs link, helped me to translate vehicle name.

One thing is confusing me a bit. When the train has 22 306 horse powers the file must contain something like 5722, 2257, 00002257 or what ever. I failed to find 22 near 57 anyway. And I am not sure, if cost I see can help me to finde the train, even if I disabled inflaction.

Second thing: is there any trick to renumerate all lines once I add/remove one (i mean editor) or I must have app for this. (doesn't the conventer check for correnc numbers itself?)
Last edited by Darker on 18 Aug 2011 15:52, edited 1 time in total.
Hacking is like sex - you get in, you get out. And then you hope that you didn't leave inside anything to track you.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Have I missed something?

Post by FooBar »

Darker wrote:And is it OK when I create tracks which blinks? (what about CPU...?)
And why the company color didn't work for tracks? (I mean: Is it possible to differ tracks with colors some other way?)

And, if you use some good freeware editor (better than Irfan or MSpaint) please recomend it to me :)
If you like blinking tracks, it's fine to create them. Don't worry about CPU, unless you have a really old computer. For slow computers the game has an option to disable "full detail", which also disables these blinking things.

Tracks don't support company colours, only depots (and stations, fences) do. If you really need it, you can always request it as a feature.

Myself I use Photoshop for drawing sprites. It's massive overkill, but I'm used to it and it has all the tools you could want. It's also massively expensive.
A free alternative is GIMP, probably also massive overkill, but at least it can handle palettes properly.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 18 guests