Request: Small change to LumpMOD desperately needed!

Software projects like source ports (3DGE, Eternity, etc), launchers like ZDL, and other useful utilities belong in this forum.
Forum rules
The Projects forums are ONLY for YOUR PROJECTS! If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.

Request: Small change to LumpMOD desperately needed!

Postby Kroc » Mon Jan 16, 2017 11:21 am

Hello all.

In simple terms, I need the help of anybody who knows a bit of C (I don't) to make a small modification to lumpmod (a program to manage the contents of WAD files). I am a programmer (just not C) so can explain precisely what's needed.

I've made DOOM-crusher, a utility to maximally compress PK3/WAD files. The problem with WAD files is that the lumpmod cannot tell me what file-type a lump is without extracting to disk first. The act of extracting every lump and working out the file-type is taking a *really* long time.

Lumpmod has a `list` option that lists the contents of a WAD, and with `-v` lists in each lump as index, name and length.
Here is a link to the exact code location that does this: https://github.com/STJr/SRB2/blob/maste ... #L595-L597

I only need to identify PNG and JPG files and this can be done with just the first four bytes of each lump. What I need is for the (above mentioned) line to also output "PNG"/"JPG" for lumps recognised as such or "LMP" for anything else.

A PNG file can easily be identified if bytes 2-4 read "PNG"
A JPG file has the first two bytes read 0xFF, 0xD8

If anybody could please make this change I'd greatly appreciate it and you'd be contributing to a tool to help all DOOM developers.

Kind regards,
Kroc Camen.
Kroc
 
Joined: 02 Oct 2016

Re: Request: Small change to LumpMOD desperately needed!

Postby Gez » Mon Jan 16, 2017 6:45 pm

That tool is part of SRB2, which is actively developed, so why not raise an issue with your demand?


Also, can't you use SLADE 3? It's not a command-line application but when it opens an archive it identifies all lumps (see all known data formats here). You could just browse through the entry list to find out which lumps are PNGs or JPGs.
Gez
 
 
 
Joined: 06 Jul 2007

Re: Request: Small change to LumpMOD desperately needed!

Postby wildweasel » Tue Jan 17, 2017 1:08 am

I suspect he needs something that can be easily automated in a batch utility, so SLADE is likely not that useful for this.
User avatar
wildweasel
I love the smell of sourdough in the morning
 
Joined: 15 Jul 2003
Location: avatar by kurashiki

Re: Request: Small change to LumpMOD desperately needed!

Postby _mental_ » Tue Jan 17, 2017 6:18 am

You need to replace lines 595 and 596 in lumpmod.c with the following code:
Code: Select allExpand view
                if(verbose) {
                    const char *format = "LMP";
                    unsigned char *data = curlump->cl->data;
                    if(data && curlump->cl->len > 16)
                        if(data[0] == 0x89 && data[1] == 0x50
                                && data[2] == 0x4E && data[3] == 0x47)
                            format = "PNG";
                        else if(data[0] == 0xFF && data[1] == 0xD8
                                && data[2] == 0xFF)
                            format = "JPG";
                    printf("%5i %-8s %7li %s\n", i,
                        get_lump_name(curlump->cl), curlump->cl->len, format);
                }

Whole modified file is here.

From OP it's not clear what's you need, compiled binary or source code.
_mental_
 
 
 
Joined: 07 Aug 2011

Re: Request: Small change to LumpMOD desperately needed!

Postby Kroc » Tue Jan 17, 2017 4:13 pm

Thank you, thank you one and all for your help.

Gez wrote:That tool is part of SRB2, which is actively developed, so why not raise an issue with your demand?


It's only a dependency that they've included in their repo; not their own source. I can still raise an issue and they may very well consider it, and I hadn't thought to do that so thank you for suggesting it.

wildweasel wrote:I suspect he needs something that can be easily automated in a batch utility, so SLADE is likely not that useful for this.


This is correct. It's unfortunate that SLADE has no command-line control. Automating of DOOM formats is surprisingly difficult.

_mental_ wrote:From OP it's not clear what's you need, compiled binary or source code.


Thank you so very much for providing the fix needed. I can read C but can't write it especially when I don't understand the program. I've compiled a number of projects before as part and parcel of being a developer using a wide variety of tools so I'm just setting up cygwin now to try compile this -- I hope that works.

A special thank you again as this simple modification will reduce 20+ minutes of lump shifting into less than a second!
Kroc
 
Joined: 02 Oct 2016


Return to Software and Ports

Who is online

Users browsing this forum: No registered users and 1 guest