GitExl / WhackEd4

As a replacement for the DOS-based Dehacked, WhackEd4 allows you to load and edit Doom Dehacked files.
http://www.teamhellspawn.com/exl/whacked4
BSD 2-Clause "Simplified" License
42 stars 7 forks source link

WhackEd4 does not detect chex.wad and chex3.wad (the 2008/2009 release) as valid IWADs. #38

Closed Acts19quiz closed 2 months ago

Acts19quiz commented 1 year ago

Version Up to and including 1.3.0 beta 2

OS Windows 10 64-bit LTSC

Installed Python version 3.10.10 64-bit

Description When trying to select the desired IWAD in the "Patch settings" dialogue box, the chex.wad and chex3.wad IWADs aren't recognized as IWADs. The reason for that is WhackEd4 relies solely on the presence of the 'IWAD' header in a selected WAD, and rejects any with the 'PWAD' header. However, any WAD created with DEUTEX (including chex.wad) has the PWAD header (unless the author uses a HEX editor).

https://github.com/GitExl/WhackEd4/blob/25cd23dbc3968c4b1d385177884953bd5a18158e/src/whacked4/doom/wad.py#LL84C1-L104C29

This is where the action takes place. An adjustment like the following could be made for the Chex Quest IWADs: `

     # Read and validate header. Should contain PWAD or IWAD magic bytes.
        wad_type, entry_count, dir_offset = self.S_HEADER.unpack(f.read(self.S_HEADER.size))
        wad_type = wad_type.decode('ascii')
        if wad_type != self.TYPE_IWAD and wad_type != self.TYPE_PWAD:
            raise WADTypeError('Invalid WAD type "{}"'.format(type))

        # Read lump directory.
        f.seek(dir_offset)
        self.lumps = []
        for _ in range(entry_count):
            offset, size, name = self.S_LUMP.unpack(f.read(self.S_LUMP.size))

            # Strip trailing NULL characters.
            name = name.decode('ascii').split('\x00')[0]

            self.lumps.append(Lump(name, size, offset, self))

    self.filename = filename
    if (wad_type == self.TYPE_PWAD and self.get_lump('E1M1') and self.get_lump('E3M1')
    and self.get_lump('W94_1') and self.get_lump('POSSH0M0')):
        wad_type = self.TYPE_IWAD
    self.type = wad_type

`

GitExl commented 2 months ago

Makes sense, I merged the pull request. Thank you!