diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs index bb557754375a9ef292b2d51c86adba9f60cf10b7..f0b0aaca62a7878f286700e7ba68d4b31eb64eca 100644 --- a/Source/Core/General/MapManager.cs +++ b/Source/Core/General/MapManager.cs @@ -401,7 +401,7 @@ namespace CodeImp.DoomBuilder // Copy the map lumps to the temp file General.WriteLogLine("Copying map lumps to temporary file..."); - CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true); + CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, true, true, true, true); // Close the map file mapwad.Dispose(); @@ -508,7 +508,7 @@ namespace CodeImp.DoomBuilder // Copy the map lumps to the temp file General.WriteLogLine("Copying map lumps to temporary file..."); - CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, true, true, true, true); + CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER, true, true, true, true); // Close the map file mapwad.Dispose(); @@ -894,7 +894,6 @@ namespace CodeImp.DoomBuilder // Determine original map name string origmapname = (!string.IsNullOrEmpty(options.PreviousName) && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName; string origwadfile = string.Empty; //mxd - int mapheaderindex = REPLACE_TARGET_MAP; //mxd. Lump index of the map file header in the source WAD try { @@ -980,7 +979,7 @@ namespace CodeImp.DoomBuilder } // Copy map lumps to target file - CopyLumpsByType(tempwad, TEMP_MAP_HEADER, targetwad, origmapname, mapheaderindex, true, true, includenodes, true); + CopyLumpsByType(tempwad, TEMP_MAP_HEADER, targetwad, origmapname, true, true, includenodes, true); // mxd. Was the map renamed? if(options.LevelNameChanged) @@ -1190,7 +1189,7 @@ namespace CodeImp.DoomBuilder // Copy lumps to buildwad General.WriteLogLine("Copying map lumps to temporary build file..."); - CopyLumpsByType(tempwad, TEMP_MAP_HEADER, buildwad, BUILD_MAP_HEADER, REPLACE_TARGET_MAP, true, false, false, true); + CopyLumpsByType(tempwad, TEMP_MAP_HEADER, buildwad, BUILD_MAP_HEADER, true, false, false, true); // Close buildwad buildwad.Dispose(); @@ -1235,7 +1234,7 @@ namespace CodeImp.DoomBuilder { // Copy nodebuilder lumps to temp file General.WriteLogLine("Copying nodebuilder lumps to temporary file..."); - CopyLumpsByType(buildwad, BUILD_MAP_HEADER, tempwad, TEMP_MAP_HEADER, REPLACE_TARGET_MAP, false, false, true, false); + CopyLumpsByType(buildwad, BUILD_MAP_HEADER, tempwad, TEMP_MAP_HEADER, false, false, true, false); } else { @@ -1435,13 +1434,11 @@ namespace CodeImp.DoomBuilder // This copies specific map lumps from one WAD to another private void CopyLumpsByType(WAD source, string sourcemapname, WAD target, string targetmapname, - int targetheaderinsertindex, //mxd bool copyrequired, bool copyblindcopy, bool copynodebuild, bool copyscript) { // Find the map header in target (mxd. Or use the provided one) - bool replacetargetmap = (targetheaderinsertindex == REPLACE_TARGET_MAP); //mxd - int tgtheaderindex = (replacetargetmap ? target.FindLumpIndex(targetmapname) : targetheaderinsertindex); //mxd + int tgtheaderindex = target.FindLumpIndex(targetmapname); if(tgtheaderindex == -1) { // If this header doesnt exists in the target @@ -1472,16 +1469,13 @@ namespace CodeImp.DoomBuilder if(sourceindex > -1) { //mxd. Don't do this when inserting a map (SaveMap() removes the old version of the map before calling CopyLumpsByType()) - if(replacetargetmap) - { - // Remove lump at target - int lumpindex = RemoveSpecificLump(target, tgtlumpname, tgtheaderindex, targetmapname, config.MapLumps); + // Remove lump at target + int lumpindex = RemoveSpecificLump(target, tgtlumpname, tgtheaderindex, targetmapname, config.MapLumps); - // Determine target index - // When original lump was found and removed then insert at that position - // otherwise insert after last insertion position - if(lumpindex > -1) targetindex = lumpindex; else targetindex++; - } + // Determine target index + // When original lump was found and removed then insert at that position + // otherwise insert after last insertion position + if(lumpindex > -1) targetindex = lumpindex; else targetindex++; if(targetindex > target.Lumps.Count) targetindex = target.Lumps.Count; // Copy the lump to the target @@ -1489,9 +1483,6 @@ namespace CodeImp.DoomBuilder Lump lump = source.Lumps[sourceindex]; Lump newlump = target.Insert(tgtlumpname, targetindex, lump.Length, false); lump.CopyTo(newlump); - - //mxd. We still need to increment targetindex... - if(!replacetargetmap) targetindex++; } else { @@ -1506,7 +1497,6 @@ namespace CodeImp.DoomBuilder } target.WriteHeaders(); //mxd - target.Compress(); // [ZZ] } }