Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
JadingTsunami

Reliable IWAD detection method

Recommended Posts

Is there a known fast, reliable method to distinguish IWADs?

 

Filename matching is an option but seems weak. Scanning lumps for specific targets (e.g., E1M1 vs. MAP01) is an option but might be slow.

 

I know that special IWADINFO lumps are an option, but that wouldn't identify vanilla IWADs.

Share this post


Link to post

Don't depend on that. The BFG edition IWADs and Chex.wad have a PWAD identifier, for example. So do most third party IWADs.

Of the IWADs I have, Chex3.wad, action2.wad, hacx2.wad and harm.wad all use PWAD instead of IWAD.

 

Share this post


Link to post
8 hours ago, Graf Zahl said:

Don't depend on that. The BFG edition IWADs and Chex.wad have a PWAD identifier, for example. So do most third party IWADs.

Of the IWADs I have, Chex3.wad, action2.wad, hacx2.wad and harm.wad all use PWAD instead of IWAD.

 

 

That's interesting, thanks - I had assumed the first four bytes would be a reliable method.

 

Is there any way to distinguish one IWAD from another, or is filename matching the only way?

Share this post


Link to post
6 hours ago, JadingTsunami said:

 

That's interesting, thanks - I had assumed the first four bytes would be a reliable method.

 

Is there any way to distinguish one IWAD from another, or is filename matching the only way? 

 

You can use the checksum for known IWADs. See the wiki

Share this post


Link to post
Posted (edited)

there are alot of official versions of almost each official iwad out there. unless you have ALL of them (are you sure you didn't forgot some? ;-), i'd say "use file name, and trust user to not cheat on you with it."

Share this post


Link to post
9 hours ago, ketmar said:

there are alot of official versions of almost each official iwad out there. unless you have ALL of them (are you sure you didn't forgot some? ;-), i'd say "use file name, and trust user to not cheat on you with it."

 

That, plus checking for the presence of a few lumps - just what ZDoom has been doing all the time.

 

Share this post


Link to post

There's a few ways to do it, and the one you choose depends on what you're trying to get out of it.

  1. Full IWAD checksum is pretty fast these days, but will fail if anything has been changed.
  2. Even faster: checksum the WAD directory. This ensures that all lumps are present, properly named, and of the correct size, making it virtually as good as a full checksum, but much faster. This method can survive slight lump changes that do not affect lump name or size.
  3. Checking filename only lets the user proclaim "this is my IWAD - use it as if it were Doom2.WAD", which could be good or bad.
  4. Filename+size is a tiny bit more reliable.
  5. Checking for key lumps is a nice middle ground

So use 1 or possibly 2 if you want to make sure it's a proper purchased IWAD. The remaining methods can provide some flexibility.

Share this post


Link to post
On 6/18/2019 at 1:47 AM, kb1 said:

There's a few ways to do it, and the one you choose depends on what you're trying to get out of it.

  1. Full IWAD checksum is pretty fast these days, but will fail if anything has been changed.
  2. Even faster: checksum the WAD directory. This ensures that all lumps are present, properly named, and of the correct size, making it virtually as good as a full checksum, but much faster. This method can survive slight lump changes that do not affect lump name or size.
  3. Checking filename only lets the user proclaim "this is my IWAD - use it as if it were Doom2.WAD", which could be good or bad.
  4. Filename+size is a tiny bit more reliable. 
  5. Checking for key lumps is a nice middle ground

So use 1 or possibly 2 if you want to make sure it's a proper purchased IWAD. The remaining methods can provide some flexibility.

well what if you wanted to user to be able to play freedoom. wouldnt rly work if it was checking against a static list of iwads

Share this post


Link to post
4 hours ago, unpleasantmarine said:

well what if you wanted to user to be able to play freedoom. wouldnt rly work if it was checking against a static list of iwads

 

Yes, it's true, although I have found fairly good lists of "common" IWADs out there.

 

The method I use is a static list of names to compare against, which is not great but seems like a "good enough" solution.

 

I could add lump checking, but I can also think of ways that might be deceiving, so I might leave well enough alone.

Share this post


Link to post

just put that list in some config file, so user can add their own -- and you won't have to worry about missing names or something. ;-)

Share this post


Link to post
Posted (edited)
6 hours ago, unpleasantmarine said:

well what if you wanted to user to be able to play freedoom. wouldnt rly work if it was checking against a static list of iwads

The official builds of Freedoom have well-known checksums anyway, and you can always detect by file name too. The standard names are freedoom1.wad, freedoom2.wad, and freedm.wad.

 

There's also a FREEDOOM (and FREEDM to detect FreeDM being used) lump in them that contains the version number

Share this post


Link to post
4 hours ago, JadingTsunami said:

The method I use is a static list of names to compare against, which is not great but seems like a "good enough" solution.

 

Unless people rename their IWADs. For example, to allow both to load on my system Ultimate Doom is called 'doom.wad' and regular Doom 1 is called 'doomu.wad'. Why? Because in ZDoom-based ports it doesn't matter but using 'doom.wad' for the more regularly used one has its advantages.

 

Except for one port, that is. Doomsday cannot handle this because it uses sloppy identification only checking the name and not the content.

 

 

Share this post


Link to post

The way ZDoom does it is that it uses a list of names to get handles on files, then identify the files based on their content rather than their names. So if you take HERETIC.WAD and rename it DOOM2.WAD, it'll detect it (because DOOM2.WAD is a name on the list) and then correctly identify it as being actually Heretic despite its name. ZDoom also offers a bunch of extra aliases you can use (as seen here).

 

(In addition to that, GZDoom allows custom IWADs with the extension .iwad or .ipk3. These custom extensions are to avoid having to scan through potentially thousands of .wad and .pk3 files at startup if a user just dumps all mod files in the same folder as the IWADs.)

Share this post


Link to post
On 6/19/2019 at 5:11 PM, unpleasantmarine said:

well what if you wanted to user to be able to play freedoom. wouldnt rly work if it was checking against a static list of iwads

 

On 6/17/2019 at 8:47 PM, kb1 said:

...depends on what you're trying to get out of it.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×