Page 1 of 1

grfdebug.log parsing tool (Updated 2007/04/14 @06:25 GMT)

Posted: 10 Apr 2007 23:08
by DaleStan
I've been meaning to do this for a long time, but I finally sat down and actually *did* it.

This tool will read grfdebug.log and the associated NFO file, and produce a grfdebug.txt with lines that look like:

Code: Select all

Retrieving graphics for feature 3, ID db.
Processing sprite 222.
Testing variable c. Value: 0.
Processing sprite 219.
Testing variable 7f, param 0. Value: 0.
Processing sprite 218.
Testing bits 1 of random value 1b.
Processing sprite 217.
Testing variable 47. Value: 1.
Processing sprite 211.
Returning real sprite number 177.
<...>
Calling callback 15 for feature 3, ID db.
Processing sprite 222.
Testing variable c. Value: 15.
Processing sprite 221.
Testing variable 47. Value: 204ff, Masked: ff.
Processing sprite 220.
Testing variable 1a. Value: ffffffff, Adjusted: ffff0370, Masked: 370.
Testing variable 47. Value: 204, Adjusted: 4.
Returning calculated callback result dc.
Returning real sprite number -1.
The listed sprite numbers, where not clearly invalid, are the in-nfo sprite numbers, not the numbers out of the log, and are in decimal. Everything else in hex. If you specify the wrong nfo file, you will get lots of warnings, and not nearly as much UI, but you'll still get the reformatted log.

Run it from the command line. It takes a single argument, which is the name of the nfo file that you want to debug. grfdebug.log must be in the same directory as the binary.
The search order for the nfo file is the same as for NFORenum:
file
file.nfo
sprites/file
sprites/file.nfo

The attachments contain the usual: A win32 binary in the first, and the source, with DOS and Unix linefeeds, in the second and third, respectively.

Re: grfdebug.log parsing tool

Posted: 11 Apr 2007 06:55
by XeryusTC
DaleStan wrote:@Xeryus: I've fixed several bugs that were in the version I gave you.
Thank you, I'll take a look later at it this week as I'm in the middle of a test week and I already spend too much time on other stuff yesterday ;).
For the rest, it was nice that I could make some sense out of the grfdebug.log really easy, it is quite hard to understand the raw grfdebug.log ;).

Posted: 14 Apr 2007 05:29
by DaleStan
Due to me not reading the documentation quite thoroughly enough, it was possible to see the line "Calling callback 1 for ...". I've changed this to "Getting random triggers for ...". The other changes should be relatively obvious, but just in case they're not:
I've changed the "Testing variable 7f00" lines to "Testing variable 7F, param 0", and eliminated the "Adjusted" and "Masked" values if they are the same as the preceding value.

One TTDPatch bug I've discovered here is that the "Value" entry is post-shift, not pre-shift, as the documentation implies. I have a fix for this, and intend to commit in time for Sunday's nightly.[0]

For those who like such things, a diff is attached.

[0] Because I won't be available to merge it Saturday night. If someone else is available and willing (merges should happen between 02:30 and 02:45 GMT) ping me on IRC.