mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
- Added some error handling for invalid wad files
- Fixed bug that allowed pasting geometry in visual mode (and the geometry becomes erroneous)
This commit is contained in:
parent
5b58693a71
commit
89f8b3542e
6 changed files with 93 additions and 32 deletions
|
@ -179,8 +179,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Called when the marked geometry has been copied.
|
||||
public virtual void OnCopyEnd() { }
|
||||
|
||||
// Called before pasting. Return false when paste should be cancelled.
|
||||
public virtual bool OnPasteBegin(PasteOptions options) { return true; }
|
||||
// Called before pasting. Override this and return true to indicate that paste is allowed to contiue.
|
||||
public virtual bool OnPasteBegin(PasteOptions options) { return false; }
|
||||
|
||||
// Called after new geometry has been pasted in. The new geometry is marked.
|
||||
public virtual void OnPasteEnd(PasteOptions options) { }
|
||||
|
|
|
@ -252,7 +252,16 @@ namespace CodeImp.DoomBuilder
|
|||
// Create temp wadfile
|
||||
tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
tempwad = new WAD(tempfile);
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
#else
|
||||
try { tempwad = new WAD(tempfile); }
|
||||
catch(Exception e)
|
||||
{
|
||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Read the map from temp file
|
||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||
|
@ -329,17 +338,35 @@ namespace CodeImp.DoomBuilder
|
|||
// Create temp wadfile
|
||||
tempfile = General.MakeTempFilename(temppath);
|
||||
General.WriteLogLine("Creating temporary file: " + tempfile);
|
||||
tempwad = new WAD(tempfile);
|
||||
#if DEBUG
|
||||
tempwad = new WAD(tempfile);
|
||||
#else
|
||||
try { tempwad = new WAD(tempfile); }
|
||||
catch(Exception e)
|
||||
{
|
||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Now open the map file
|
||||
General.WriteLogLine("Opening source file: " + filepathname);
|
||||
mapwad = new WAD(filepathname, true);
|
||||
|
||||
#if DEBUG
|
||||
mapwad = new WAD(filepathname, true);
|
||||
#else
|
||||
try { mapwad = new WAD(filepathname, true); }
|
||||
catch(Exception e)
|
||||
{
|
||||
General.ShowErrorMessage("Error while opening source wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Copy the map lumps to the temp file
|
||||
General.WriteLogLine("Copying map lumps to temporary file...");
|
||||
CopyLumpsByType(mapwad, options.CurrentName, tempwad, TEMP_MAP_HEADER,
|
||||
true, true, true, true);
|
||||
|
||||
|
||||
// Close the map file
|
||||
mapwad.Dispose();
|
||||
|
||||
|
@ -678,8 +705,17 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
// Make the temporary WAD file
|
||||
General.WriteLogLine("Creating temporary build file: " + tempfile1);
|
||||
buildwad = new WAD(tempfile1);
|
||||
|
||||
#if DEBUG
|
||||
buildwad = new WAD(tempfile1);
|
||||
#else
|
||||
try { buildwad = new WAD(tempfile1); }
|
||||
catch(Exception e)
|
||||
{
|
||||
General.ShowErrorMessage("Error while creating a temporary wad file:\n" + e.GetType().Name + ": " + e.Message, MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Determine source file
|
||||
if(filepathname.Length > 0)
|
||||
sourcefile = filepathname;
|
||||
|
@ -715,10 +751,19 @@ namespace CodeImp.DoomBuilder
|
|||
if(compiler.Run())
|
||||
{
|
||||
// Open the output file
|
||||
buildwad = new WAD(tempfile2);
|
||||
try { buildwad = new WAD(tempfile2); }
|
||||
catch(Exception e)
|
||||
{
|
||||
General.WriteLogLine(e.GetType().Name + " while reading build wad file: " + e.Message);
|
||||
buildwad = null;
|
||||
}
|
||||
|
||||
if(buildwad != null)
|
||||
{
|
||||
// Output lumps complete?
|
||||
lumpscomplete = VerifyNodebuilderLumps(buildwad, BUILD_MAP_HEADER);
|
||||
}
|
||||
|
||||
// Output lumps complete?
|
||||
lumpscomplete = VerifyNodebuilderLumps(buildwad, BUILD_MAP_HEADER);
|
||||
if(lumpscomplete)
|
||||
{
|
||||
// Copy nodebuilder lumps to temp file
|
||||
|
@ -735,7 +780,7 @@ namespace CodeImp.DoomBuilder
|
|||
}
|
||||
|
||||
// Done with the build wad
|
||||
buildwad.Dispose();
|
||||
if(buildwad != null) buildwad.Dispose();
|
||||
}
|
||||
|
||||
// Clean up
|
||||
|
|
|
@ -196,9 +196,11 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
// Number of lumps
|
||||
numlumps = reader.ReadInt32();
|
||||
if(numlumps < 0) throw new IOException("Invalid number of lumps in wad file.");
|
||||
|
||||
// Lumps table offset
|
||||
lumpsoffset = reader.ReadInt32();
|
||||
if(lumpsoffset < 0) throw new IOException("Invalid lumps offset in wad file.");
|
||||
|
||||
// Seek to the lumps table
|
||||
file.Seek(lumpsoffset, SeekOrigin.Begin);
|
||||
|
|
|
@ -2488,17 +2488,20 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public List<int> GetMultipleNewTags(int count)
|
||||
{
|
||||
List<int> newtags = new List<int>(count);
|
||||
Dictionary<int, bool> usedtags = new Dictionary<int, bool>();
|
||||
ForAllTags(NewTagHandler, false, usedtags);
|
||||
ForAllTags(NewTagHandler, true, usedtags);
|
||||
|
||||
// Find unused tags and add them
|
||||
for(int i = 1; i <= General.Map.FormatInterface.MaxTag; i++)
|
||||
if(count > 0)
|
||||
{
|
||||
if(!usedtags.ContainsKey(i))
|
||||
Dictionary<int, bool> usedtags = new Dictionary<int, bool>();
|
||||
ForAllTags(NewTagHandler, false, usedtags);
|
||||
ForAllTags(NewTagHandler, true, usedtags);
|
||||
|
||||
// Find unused tags and add them
|
||||
for(int i = 1; i <= General.Map.FormatInterface.MaxTag; i++)
|
||||
{
|
||||
newtags.Add(i);
|
||||
if(newtags.Count == count) break;
|
||||
if(!usedtags.ContainsKey(i))
|
||||
{
|
||||
newtags.Add(i);
|
||||
if(newtags.Count == count) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2509,19 +2512,22 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public List<int> GetMultipleNewTags(int count, bool marked)
|
||||
{
|
||||
List<int> newtags = new List<int>(count);
|
||||
Dictionary<int, bool> usedtags = new Dictionary<int, bool>();
|
||||
ForAllTags(NewTagHandler, marked, usedtags);
|
||||
|
||||
// Find unused tags and add them
|
||||
for(int i = 1; i <= General.Map.FormatInterface.MaxTag; i++)
|
||||
if(count > 0)
|
||||
{
|
||||
if(!usedtags.ContainsKey(i))
|
||||
Dictionary<int, bool> usedtags = new Dictionary<int, bool>();
|
||||
ForAllTags(NewTagHandler, marked, usedtags);
|
||||
|
||||
// Find unused tags and add them
|
||||
for(int i = 1; i <= General.Map.FormatInterface.MaxTag; i++)
|
||||
{
|
||||
newtags.Add(i);
|
||||
if(newtags.Count == count) break;
|
||||
if(!usedtags.ContainsKey(i))
|
||||
{
|
||||
newtags.Add(i);
|
||||
if(newtags.Count == count) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return newtags;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
return (General.Map.Map.GetMarkedVertices(true).Count > 0) ||
|
||||
(General.Map.Map.GetMarkedThings(true).Count > 0);
|
||||
}
|
||||
|
||||
|
||||
// This is called when pasting begins
|
||||
public override bool OnPasteBegin(PasteOptions options)
|
||||
{
|
||||
// These modes support pasting
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is called when something was pasted.
|
||||
public override void OnPasteEnd(PasteOptions options)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
using CodeImp.DoomBuilder.VisualModes;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
Loading…
Reference in a new issue