Page 1 of 22

NFORenum v3.4.6 released (NFO renumberer and linter)

Posted: 11 Nov 2004 07:07
by DaleStan
UPDATE: NFORenum is now being maintained by members of the OpenTTD project. A thread discussing the latest preview release (as of August 2010) can be found here.

-------------------------------------------------------------------------------------------------------------------------------------

I have officially Gotten Tired of renumbering my NFO files by hand, and of having to copy and paste my 424-character-long ruler every time I code a pseudo-sprite longer than about 10 bytes.

Actually, that happened about the second time I renumbered an NFO file, I just didn't do anything about it until now.

Since I could not find renum.pl, I produced this GPLed (#include <std/no_warranty.h>) tool. (EDIT:Csaboka's right, renum.pl is in the source .zip.)


The source should compile with Visual Studio .NET, gcc 3.4.x, and gcc 4.
Source from before the move to SVN is available upon request.

UPDATE:

Version 3.4.6 released.
Features:
- Numbers all non-comment, non-blank lines.
- Corrects the size of pseudo-sprites.
- Comments are never modified, regardless of location.
- Spacing between bytes in pseudosprites is preserved.
- Creates a backup of of the file to be modified, unless the backup already exists.
- Sanity checks on input files, to help prevent renumbering, for example, GRF files.
- Outputs NFO header if one is not detected.
- Outputs correct sprite 0 on TTDPatch NFOs.
- Checks all sprites for validity.
- Supports strings, binary includes, binary imports, and recolor maps.
- Permits calculations and variables in realsprites.
- Accepts strings with UTF-8 encoded characters.
- Command-line arguments for globally applicable settings, including several comment-commands.
- Optionally, rewrites sprites in a more readable format.
- Optionally, attempt to correct faulty pseudosprites.

Changelog:
v3.4.5 to v3.4.6
- Data file updates for stations; canals; houses; industries; actions 2, 5, 7/9, B, and D; languages; TextIDs; and callbacks.
- Fixed parameter check for global 60+x variables.
- Allow variational 2s to take var 1A with an <and-mask> of 0.
- Check that variational 2 operator 0F's left-hand side side was stored.
- Prohibit storing to persistent registers when they don't exist.
- Fix several bugs in the formatting of variable-length properties.
- Check cargo types against the cargo translation table.
- Add \2ror and \2rot for Adv2 op 11.
- Add \d<YMD> and \d<DMY> to generate long format intro dates.

v3.4.4 to v3.4.5
- Data file updates for signals, snowline, and TextIDs
- Fix yet more array index vs char* problems.
- Add offset info to a message that failed to have it.
- Ensure that VERSIONCHECK gets its required two arguments.
- Fix version 1 industry production callback support.
- Support Action 7/9's new GRFID/mask format.
- (minime) Allow @@LET variables to be redefined.

v3.4.3 to v3.4.4
- Data file updates for industry tiles, industries, and objects.
- Make unknown action 5 types look for real sprites or recolor sprites.
- Recognize action 2 operations 0E, 0F, and 10
- Catch Action Fs that chain to themselves.
- Add escapes for the new action 2 operations 0E and 0F.
- Support new signals. (Actions 5, variational 2, and 3.)
- Process var. and random 2s and action 3 even when the feature is not recognized.
- (fix) Don't correct the feature of a var. or random 2 to match the preceding action 1.
- Industry production callback version 1.
- Produce a useful error message when data files are out of sync with each other.
- Make --data also report the data-file location.
- Check for duplicate IDs in an action 3.
- Check that prop 08 has been set before the action 3, when necessary.

v3.4.2 to v3.4.3
- Action 1/2/3 for bridges (Callback 33)
- Data file updates for vehicles, stations, action 7/9, TextIDs
- Add $HOMEDRIVE$HOMEPATH to the list of search paths for .renum/
- Allow multiple sizes for some action 7/9 variables.
- Accept GRF version 7 lang-id bytes in action Bs that preceed the action 8.
- Allow Action 6 <param-size> entries with bit 7 set.

Posted: 11 Nov 2004 09:27
by Csaboka
Renum.pl (written by Patchman) is surely included in the TTDPatch source file, but just in case someone's too lazy to download that, I'll include it in this post.

Since it's written in Perl, you'll need Perl to run it.

It doesn't just renumber the lines, it calculates the sizes of pseudo-sprites as well, and removes comments. You can for example start every pseudo-sprite with "0 * 0" because the script will fix both zeros to valid numbers.

Usage:
perl <path>renum.pl <path>yourfile.nfo

PS: After some extensive using, I found a bug as well: if the last line of your nfo is a comment, renum.pl seems to eat the last meaningful line as well. For a workaround, put a new line with only a space in it in the last line, so your comment will be in the last but one line.

Posted: 11 Nov 2004 10:37
by DaleStan
I should have known I'd forget something if I posted after midnight. In this case, that something was the feature list. I think that feature list is complete.

The list doesn't exist anyplace else, except by the "There's a known issue regarding this feature, hence the feature must exist" reasoning.

Re: NFO renumbering tool v0.2 released

Posted: 11 Nov 2004 20:40
by DaleStan
Version 0.2 is released.

Changelog:
- No longer silently destroys data in multi-line pseudo sprites. (It's quite noisy about it now.)
- Detects TTDPatch NFOs, and reports size stats.
- In TTDPatch NFOs, if sprite 0 does not report the exact size of the NFO, outputs corrected sprite 0 to the console, and, commented, as the last line of the NFO.
- Renum.bat will not delete the old version of the NFO if pseudosprite data may have been destroyed.
- Redefined return values.

See first post for full details and download.

Posted: 19 Nov 2004 07:35
by DaleStan
One of these days, I'll remember that I've fixed a few things and need to post a new version.

Version 0.3 is released.
It contains mostly bugfixes.

Changelog:
- Now also reports on potential continued pseudo-sprites with trailing comments
- No longer eats whitespace before comments
- No longer eats blank lines

See first post for full details and download.

Posted: 19 Nov 2004 08:59
by DaleStan
OK, now that that's fixed (please don't ask me how I failed to catch it)

Version 0.3.1 (bugfix) is released.
Changelog:
- No longer destroys real sprites.

See first post for full details and download.[/quote]

Posted: 23 Nov 2004 00:10
by JEB
I tried the newer program and as you said it splits pseudo sprite lines.

You should be able to fix this. I had the same problem whien I first stated
my NFO alter/reader program. So keep at it you will fix it!

I like the program except for that.

What are you programmin in?

JEB

Posted: 23 Nov 2004 01:44
by DaleStan
JEB wrote:I tried the newer program and as you said it splits pseudo sprite lines.
You should be able to fix this. I had the same problem whien I first stated
my NFO alter/reader program. So keep at it you will fix it!
The workaround is, of course, to manually remove the linefeeds that GRFCodec puts in, but I realized this was not an acceptable workaround when looking at the code for the USSet, so that is now #2 on my TODO. #1 is to test (Win32 and Linux versions. Sorry, I don't have a Mac, but stubs will be there if anyone wants to finish it), fix, and upload the version that does its own file handling, to free up standard in and -out for interactive use. This will also enable renum to write a correct sprite 0 at the correct location, instead of at the end of the file.

There are particularly obstinate lines, like

Code: Select all

10 AD 10 15 01 15 15 10 10
that are perfectly valid as both as a continuation line of a pseudo-sprite, and as a real sprite, but this is a pathological case.
Actually, since I ignore whitespace completely in pseudo-sprite checking (and GRFCodec apparently does too),

Code: Select all

10 AD 10 15 01 15 15 1 1
which is slightly more likely, would also be valid as either continued pseudo sprite, or real sprite.

I think I'll just count both of those as continued sprites, and leave this gem in the known issue file:
Known Issue:
- Real sprites in PCX files with two-character names and no extention, where both characters are valid hex digits, may be attached to the preceding sprite if it is a pseudo sprite.
Status: Not a bug.
Come to think of it, I can make it even more specific, and only cause problems if the preceding pseudo sprite was not an action 1, ie only in(possibly) TTD's original GRF files, which really shouldn't be renumbered anyway, or very broken TTDPatch GRFs.
JEB wrote:What are you programmin in?
C++.

Posted: 29 Nov 2004 07:41
by DaleStan
v0.4 is more internal changes than anything else, but a lot of (partly intentional) side effects came along with it.

Changelog:
v0.3.1 to v0.4
- (devel) Now does its own file handling (disable by #defining NO_FILE_HANDLING)
- Accepts absolute paths for .NFO locations.
- Drag&drop from Windows explorer now works.
- The executable is now UPX packed.
- renum.bat is no longer necessary; the executable is now renum.exe.
- GNU/Linux systems (GNU fileutils) receive a new backup everytime the NFO is renumbered.

See first post for full details and download.

Posted: 30 Nov 2004 01:17
by DaleStan
I have fixed that multi-line pseudo-sprite problem, and decided that it's time to increment the major version number.

Changelog:
v0.4 to v1.0
- Now handles multi-line pseudo-sprites correctly. (And there was much rejoicing.)
- Now writes sprite 0 in the correct location.
- More permissive TTDPatch NFO detection--if the first sprite is a pseudo-sprite, treat as a TTDPatch NFO.
- Successful runs no longer produce output, other than the fixed NFOs.
- (devel) Now stores most of the NFO in memory while processing.

See first post for full details and download.

Posted: 02 Dec 2004 12:50
by Mek
hmm.. why is it both this program and the renum.pl don't support the nice strings the latest grfcodec supports? no i still have to do the counting myself...

Posted: 03 Dec 2004 00:35
by DaleStan
Mek wrote:hmm.. why is it both this program and the renum.pl don't support the nice strings the latest grfcodec supports? no i still have to do the counting myself...
Because I didn't know that feature existed?
EXPN, please, or point me to where it is explained.
What's the version number for "latest"? and if it's not 0.9.5 where can it be found?

I just released a new version, but I doubt I managed to implement this request.

Changelog:
v1.0 to v1.1
- Now processes all files listed on the command line.
- Always produces output. (If I could just make a decision here...)
- Warning and error messages will now be sent to both the console and the NFO.
- Changed handling of invalid pseudo-sprites. Instead of dying, comments the sprite out and continues.
- (Bugfix) Added a check to ensure that the output file actually got opened.

See the first post for more details and download.

Posted: 03 Dec 2004 12:16
by Mek
DaleStan wrote:
Mek wrote:hmm.. why is it both this program and the renum.pl don't support the nice strings the latest grfcodec supports? no i still have to do the counting myself...
Because I didn't know that feature existed?
EXPN, please, or point me to where it is explained.
What's the version number for "latest"? and if it's not 0.9.5 where can it be found?
Hmm yes... you're right.. this feature isn't in the latest grf codec available. Since i'm running linux, I applied the unix patch to the 0.9.5 source, and apparently this doesn't only make grfcodec compatible with linux, but it also adds support for strings...

Posted: 03 Dec 2004 20:05
by DaleStan
Well, I'll see what I can do.
Between Cygwin and this Linux box sitting next to me[0] I should be able to get something to work.

I'm making progress on sanity checking pseudo-sprites. I have coded (but not tested) checks for 1 and 5, as well as the data section that follows them. (all 1 byte pseudo-sprites are taken to be real sprites, to accomodate USSet, CSDset, and probably others.)

And in the "Let's be honest" department, v1.0 introduced another bug.
- Continuation lines of pseudo-sprites containing invalid characters will silently be destroyed, as will all following lines of that pseudo-sprite.

[0]FSVO "box" It runs beautifully as a console, but cannot handle X.

Posted: 08 Dec 2004 00:43
by DaleStan
New version.

Changelog:
v1.1 to v1.2
- Now adds missing NFO header.
- Checks real sprites for validity. This mostly solves the problem of destroying continuation pseudo-sprite lines with invalid characters.
- Corrected backup and temp file names in some cases.

See the first post for more details and download.

I am unable to get the GRFCodec source to compile (report over here), so I would have no way of properly testing string support were I to put it in.

Posted: 08 Dec 2004 07:20
by DaleStan
Grr... Another bugfix. At least it's not as urgent as 0.3.1.

Changelog:
v1.2 to v1.2.1
- Fixed real-sprite validity check to agree with GRFCodec.
- Fixed condition where sprites could get numbered in hex.

See the first post for more details and download.

Posted: 18 Dec 2004 23:46
by DaleStan
Yes, I bumped the major version number again.

Two new features here: sanity checking and comment commands.

Sanity checking will check the NFO for pseudo-sprites with incorrect length, insufficient/excessive real sprites, potential mistakes, and anything else I deem incorrect. Output is to both the console and the NFO.

The comment commands can tell NFORenum to remove old messages from the NFO, so you don't have to manually remove messages when you fix a problem.
Comment commands also control sanity checking, to help keep it from outputting incorrect/unnecessary messages.

See the README for more information on how these work.

Changelog:
v1.2.1 to v2.0
- Added sanity checking for Actions 1-3, 5, and A
- Added comment commands.
- Changed *nix version to look in the "sprites/" directory.

See the first post for more details and download.

Posted: 20 Dec 2004 00:26
by JEB
very good program, has saved me lots of work.
I added it to GRFMENU. A menu program that
allows me to not have to always change a bat
files name. I realeased a version of it here
last spring.

JEB

Posted: 20 Dec 2004 20:07
by DaleStan
Bugfix, and a little bit more sanity checking.

v2.0 to v2.0.1
- Added sanity checking to ensure that there is a chain from all vehicle sprites to an action 3.
- Added a comment command (USESET) to work around unchecked Action 6s
- Fixed condition where certian pseudosprite continuations could be replaced with real sprites.

See the first post for more details and download.

Posted: 22 Dec 2004 07:47
by George
What is wrong with the following line?

//!!Sanity warning: Var02 declaring no variations
167 * 10 02 00 3A 81 41 00 FF 00 1A 00