sirjuddington / SLADE

It's a Doom editor
https://slade.mancubus.net
GNU General Public License v2.0
710 stars 109 forks source link

WAD lumps with merged data are being discarded #1218

Open jendalinda opened 3 years ago

jendalinda commented 3 years ago

SLADE Version: 3.2.0 beta 2 Operating System: Windows

Issue Details:

If a WAD archive contains merged lumps - more lump entries share the same data in the WAD archive - SLADE loads only the first entry pointing to the data and other entries are ignored. When the WAD archive is then saved, the ignored entries are lost.

These WAD archives can be produced by some WAD utilities, for example WADPTR

Testing the issue:

Create a WAD archive and import some files with the same content. In my example, I've imported three files:

  1. file SONG1, SONG2
  2. file SONG3, SONG4, SONG6
  3. file SONG5

My example archive (I'm using wadptr to list the contents of the archive):

Number Length Offset Method Name Shared ------ ------ ------ ------ ---- ------ 1 24253 0x0000000c Stored SONG1 No 2 24253 0x00005ec9 Stored SONG2 No 3 40075 0x0000bd86 Stored SONG3 No 4 40075 0x00015a11 Stored SONG4 No 5 22097 0x0001f69c Stored SONG5 No 6 40075 0x00024ced Stored SONG6 No

Optimize the WAD archive using WADPTR, the resulting archive looks like this:

Number Length Offset Method Name Shared ------ ------ ------ ------ ---- ------ 1 24253 0x0000000c Stored SONG1 No 2 24253 0x0000000c Stored SONG2 SONG1 3 40075 0x00005ec9 Stored SONG3 No 4 40075 0x00005ec9 Stored SONG4 SONG3 5 22097 0x0000fb54 Stored SONG5 No 6 40075 0x00005ec9 Stored SONG6 SONG3

Open the WAD archive in SLADE. In my case, only SONG1, SONG3 and SONG5 are listed. In the SLADE console, there are these warnings:

Ignoring entry 1: SONG2, is a clone of a previous entry Ignoring entry 3: SONG4, is a clone of a previous entry Ignoring entry 5: SONG6, is a clone of a previous entry

Save the WAD archive. The ignored lump entries are lost:

Number Length Offset Method Name Shared ------ ------ ------ ------ ---- ------ 1 24253 0x0000000c Stored SONG1 No 2 40075 0x00005ec9 Stored SONG3 No 3 22097 0x0000fb54 Stored SONG5 No

Suggested solution:

Editing WAD archives with merged lump data is complicated. However there should be a non destructive way to handle such archives.

SLADE might load those WAD archives readonly, allowing viewing and exporting the contents. When saving the WAD archive, SLADE should expand the merged lump data into individual copies.

sirjuddington commented 3 years ago

This one is a bit tricky, because in the past this has been used to create troll wads with lots of clones of a single entry, which would eventually crash SLADE if opened. It's something to look at possibly supporting safely at some point, but a low priority.

jendalinda commented 3 years ago

I see the point. As a temporary solution, Slade should at least display a warning (a message box) that cloned entries will be removed upon saving.

MrAlaux commented 1 month ago

I hope you don't mind me bumping this; I too am interested in being able to at least display the duplicates. I'd be happy with a simple toggle hidden away in the Advanced options tab.