mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Revert "Fixed a bug where saving WADs that didn't have their data starting right after the header would corrupt the file. Fixes #531"
This reverts commit 6c55197264
.
This commit is contained in:
parent
8883335da8
commit
daf38b5bd3
1 changed files with 6 additions and 49 deletions
|
@ -953,39 +953,16 @@ namespace CodeImp.DoomBuilder
|
||||||
// Treat "save as" into the current archive as normal save.
|
// Treat "save as" into the current archive as normal save.
|
||||||
bool isSaveAs = (purpose == SavePurpose.AsNewFile) && (newfilepathname != filepathname);
|
bool isSaveAs = (purpose == SavePurpose.AsNewFile) && (newfilepathname != filepathname);
|
||||||
// On Save AS we have to copy the previous file to the new file
|
// On Save AS we have to copy the previous file to the new file
|
||||||
if (isSaveAs)
|
if(isSaveAs)
|
||||||
{
|
{
|
||||||
// Copy if original file still exists
|
// Copy if original file still exists
|
||||||
if (File.Exists(filepathname))
|
if(File.Exists(filepathname)) File.Copy(filepathname, newfilepathname, true);
|
||||||
File.Copy(filepathname, newfilepathname, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(newfilepathname))
|
// If the target file exists, we need to rebuild it
|
||||||
{
|
// [ZZ] The original code here would do some weird trickery with tempfiles.
|
||||||
// If the target file exists, we need to rebuild it
|
// I'm just finding the map lumps and deleting them on later stages.
|
||||||
// biwa. This somewhat restores the behavior that was change with commit b996d8a380056ed9cb3a3f90f3c534e29e77e53c
|
targetwad = new WAD(newfilepathname);
|
||||||
// Not rebuilding the WAD can cause issues with WADs that do not have their directory at the bottom.
|
|
||||||
// See https://github.com/jewalky/UltimateDoomBuilder/issues/531
|
|
||||||
origwadfile = newfilepathname + ".temp";
|
|
||||||
File.Move(newfilepathname, origwadfile);
|
|
||||||
|
|
||||||
// Open original file
|
|
||||||
WAD origwad = new WAD(origwadfile, true);
|
|
||||||
|
|
||||||
// Create new target file
|
|
||||||
targetwad = new WAD(newfilepathname) { IsIWAD = origwad.IsIWAD }; //mxd. Let's preserve wad type
|
|
||||||
|
|
||||||
CopyAllLumps(origwad, targetwad);
|
|
||||||
|
|
||||||
// Close original file and delete it
|
|
||||||
origwad.Dispose();
|
|
||||||
File.Delete(origwadfile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Create new target file
|
|
||||||
targetwad = new WAD(newfilepathname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1576,26 +1553,6 @@ namespace CodeImp.DoomBuilder
|
||||||
return tgtheaderindex;
|
return tgtheaderindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Copies all lumps from one WAD to another
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source">Source WAD</param>
|
|
||||||
/// <param name="target">Target WAD</param>
|
|
||||||
private static void CopyAllLumps(WAD source, WAD target)
|
|
||||||
{
|
|
||||||
// Go for all lumps
|
|
||||||
for (int i = 0; i < source.Lumps.Count; i++)
|
|
||||||
{
|
|
||||||
Lump srclump = source.Lumps[i];
|
|
||||||
|
|
||||||
// Copy lump over!
|
|
||||||
Lump tgtlump = target.Insert(srclump.Name, target.Lumps.Count, srclump.Length, false);
|
|
||||||
srclump.CopyTo(tgtlump);
|
|
||||||
}
|
|
||||||
|
|
||||||
target.WriteHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This copies specific map lumps from one WAD to another
|
// This copies specific map lumps from one WAD to another
|
||||||
private void CopyLumpsByType(WAD source, string sourcemapname,
|
private void CopyLumpsByType(WAD source, string sourcemapname,
|
||||||
WAD target, string targetmapname,
|
WAD target, string targetmapname,
|
||||||
|
|
Loading…
Reference in a new issue