diff --git a/Build/Scripting/ZDoom_ACS.cfg b/Build/Scripting/ZDoom_ACS.cfg
index 9a7e828..b766417 100644
--- a/Build/Scripting/ZDoom_ACS.cfg
+++ b/Build/Scripting/ZDoom_ACS.cfg
@@ -57,7 +57,7 @@ keywords
ActivatorTID = "int ActivatorTID(void)";
AmbientSound = "void AmbientSound(str sound, int volume)";
//AnnouncerSound = "void AnnouncerSound(str sound, int flags)";
- Autosave = "Autosave()";
+ Autosave = "Autosave(void)";
//BlueCount = "BlueCount()";
//BlueReturn = "Script expression BlueReturn";
//BlueScore = "BlueScore()";
@@ -174,8 +174,8 @@ keywords
FloorAndCeiling_LowerByValue = "FloorAndCeiling_LowerByValue(tag, speed, height)";
FloorAndCeiling_LowerRaise = "FloorAndCeiling_LowerRaise(tag, fspeed, cspeed, boomemu)";
FloorAndCeiling_RaiseByValue = "FloorAndCeiling_RaiseByValue(tag, speed, height)";
- for = "for(initialization, condition, iteration)";
- ForceField = "ForceField";
+ for = "for(initialization; condition; iteration)";
+ ForceField = "ForceField(void)";
FS_Execute = "FS_Execute(script, side, keynum, message)";
function = "function void expression(void)";
GameSkill = "int GameSkill(void)";
@@ -413,7 +413,7 @@ keywords
Spawn = "int Spawn(str classname, fixed x, fixed y, fixed z[, int tid[, int angle]])\nSpawns an actor at the given X, Y and Z coordinates.\nOptionally a TID and a byte angle can be specified.";
SpawnForced = "int SpawnForced(str classname, fixed x, fixed y, fixed z[, int tid[, int angle]])\nForces the actor to spawn, even in conditions where the spawning would normally fail.\nThe return value is the number of things spawned.";
SpawnDecal = "int SpawnDecal(int tid, str decalname, int flags[, fixed angle = 0.0[, fixed zoffset = 0.0[, fixed distance = 64.0]]])\nCreates a decal on a wall by tracing a line from the actor with the\nspecified tid until hitting said wall, on which the decal is then created.\nIf tid is 0, the tracing is done from the activator of the script.\ndecalname: The name of the decal to create, as defined in DECALDEF.\nflags: use SDF_ flags\nThe return value of the function is the number of decals spawned.";
- SpawnParticle = "void SpawnParticle(float offx, float offy, float offz, float velx, float vely, float velz, color color1, int lifetime[, bool fullbright = false[, float startalpha = 1.0[, int size = 1[, float fadestep = -1[, float accelx = 0[, float accely = 0[, float accelz = 0]]]]]]])";
+ SpawnParticle = "void SpawnParticle(int color[, bool fullbright = false[, int lifetime = 35[, int size = 1[, fixed x = 0.0[, fixed y = 0.0[, fixed z = 0.0[, fixed velx = 0.0[, fixed vely = 0.0[, fixed velz = 0.0[, fixed accelx = 0.0[, fixed accely = 0.0[, fixed accelz = 0.0[, int startalpha = 255[, int fadestep = -1]]]]]]]]]]]]]])";
SpawnProjectile = "void SpawnProjectile(int tid, str type, int angle, int speed, int vspeed, int gravity, int newtid)";
SpawnSpot = "int SpawnSpot(str classname, int spottid[, int tid[, int angle]])\nRequires a MapSpot at the location where you want the Actor to spawn.\nThe return value is the number of things spawned.";
SpawnSpotFacing = "int SpawnSpotFacing(str classname, int spottid[, int tid])\nRequires a MapSpot at the location where you want the Actor to spawn.\nThe thing will assume the angle of the mapspot it is spawned to.\nThe return value is the number of things spawned.";
@@ -444,7 +444,7 @@ keywords
TakeActorInventory = "void TakeActorInventory(int tid, str inventory_item, int amount)\nThis function will take the amount of items from the specified actor.\nTakeActorInventory can remove items that are flagged as undroppable.";
TakeInventory = "void TakeInventory(str inventory_item, int amount)\nThis function will take the number of items specified from the activator.\nTakeInventory can remove items that are flagged as undroppable.";
Teleport = "Teleport(tid, tag, nosourcefog)";
- Teleport_EndGame = "Teleport_EndGame()";
+ Teleport_EndGame = "Teleport_EndGame(void)";
Teleport_NewMap = "Teleport_NewMap(map, pos, face)";
Teleport_NoFog = "Teleport_NoFog(tid, useangle, tag)";
Teleport_NoStop = "Teleport_NoStop(tid, tag, nofog)";
diff --git a/Build/Scripting/ZDoom_DECORATE.cfg b/Build/Scripting/ZDoom_DECORATE.cfg
index be3057b..3b922c2 100644
--- a/Build/Scripting/ZDoom_DECORATE.cfg
+++ b/Build/Scripting/ZDoom_DECORATE.cfg
@@ -124,7 +124,7 @@ keywords
A_SpawnDebris = "A_SpawnDebris(str type[, bool translation = false[, float horizontal_vel = 1.0[, float vertical_vel = 1.0]]])";
A_SpawnItem = "A_SpawnItem(str type, int distance, float zpos, bool useammo, bool translation)";
A_SpawnItemEx = "A_SpawnItemEx(str type[, float xoffset = 0.0[, float yoffset = 0.0[, float zoffset = 0.0[, float xvelocity = 0.0[, float yvelocity = 0.0[, float zvelocity = 0.0[, float angle = 0.0[, int flags = 0[, int skipchance = 0[, int tid = 0]]]]]]]]]])";
- A_SpawnParticle = "A_SpawnParticle(float offx, float offy, float offz, float velx, float vely, float velz, color color1, int lifetime[, bool fullbright = false[, float startalpha = 1.0[, int size = 1[, float fadestep = -1[, float accelx = 0[, float accely = 0[, float accelz = 0]]]]]]])";
+ A_SpawnParticle = "A_SpawnParticle(color color[, int flags = 0[, int lifetime = 35[, int size = 1[, float angle = 0.0[, float xoff = 0.0[, float yoff = 0.0[, float zoff = 0.0[, float velx = 0.0[, float vely = 0.0[, float velz = 0.0[, float accelx = 0.0[, float accely = 0.0[, float accelz = 0.0[, float startalpha = 1.0[, float fadestep = -1.0]]]]]]]]]]]]]]])";
//State jumps
A_CheckBlock = "A_CheckBlock(str block[, int flags = 0[, int pointer = AAPTR_TARGET]])";
A_CheckCeiling = "A_CheckCeiling(int offset OR str state)";
diff --git a/Source/Core/Actions/ActionManager.cs b/Source/Core/Actions/ActionManager.cs
index f93ad4e..dbc4ae9 100644
--- a/Source/Core/Actions/ActionManager.cs
+++ b/Source/Core/Actions/ActionManager.cs
@@ -121,7 +121,7 @@ namespace CodeImp.DoomBuilder.Actions
foreach(string rn in resnames)
{
// Found one?
- if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream actionsdata = asm.GetManifestResourceStream(rn);
diff --git a/Source/Core/Actions/BeginActionAttribute.cs b/Source/Core/Actions/BeginActionAttribute.cs
index e82ca05..36b447e 100644
--- a/Source/Core/Actions/BeginActionAttribute.cs
+++ b/Source/Core/Actions/BeginActionAttribute.cs
@@ -23,7 +23,7 @@ namespace CodeImp.DoomBuilder.Actions
///
/// This binds a method to an action which is then called when the action is started.
///
- public class BeginActionAttribute : ActionAttribute
+ public sealed class BeginActionAttribute : ActionAttribute
{
///
/// This binds a method to an action which is then called when the action is started.
diff --git a/Source/Core/Actions/EndActionAttribute.cs b/Source/Core/Actions/EndActionAttribute.cs
index e796eeb..27fffca 100644
--- a/Source/Core/Actions/EndActionAttribute.cs
+++ b/Source/Core/Actions/EndActionAttribute.cs
@@ -23,7 +23,7 @@ namespace CodeImp.DoomBuilder.Actions
///
/// This binds a method to an action which is then called when the action is stopped.
///
- public class EndActionAttribute : ActionAttribute
+ public sealed class EndActionAttribute : ActionAttribute
{
///
/// This binds a method to an action which is then called when the action is stopped.
diff --git a/Source/Core/Actions/HintsManager.cs b/Source/Core/Actions/HintsManager.cs
index f9e9049..942665f 100644
--- a/Source/Core/Actions/HintsManager.cs
+++ b/Source/Core/Actions/HintsManager.cs
@@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Actions
foreach(string rn in resnames)
{
// Found one?
- if(rn.EndsWith(HINTS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(HINTS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
string classname = string.Empty;
string groupname = string.Empty;
diff --git a/Source/Core/Config/ConfigurationInfo.cs b/Source/Core/Config/ConfigurationInfo.cs
index aa3212d..5856f44 100644
--- a/Source/Core/Config/ConfigurationInfo.cs
+++ b/Source/Core/Config/ConfigurationInfo.cs
@@ -236,7 +236,8 @@ namespace CodeImp.DoomBuilder.Config
~ConfigurationInfo()
{
foreach(ThingsFilter tf in thingsfilters) tf.Dispose();
- }
+ foreach(EngineInfo ei in testEngines) ei.Dispose();
+ }
#endregion
diff --git a/Source/Core/Controls/FieldsEditorControl.cs b/Source/Core/Controls/FieldsEditorControl.cs
index a980da0..ac4c39a 100644
--- a/Source/Core/Controls/FieldsEditorControl.cs
+++ b/Source/Core/Controls/FieldsEditorControl.cs
@@ -382,9 +382,9 @@ namespace CodeImp.DoomBuilder.Controls
fieldslist.CurrentCell = fieldslist.SelectedRows[0].Cells[0];
fieldslist.CurrentCell.ReadOnly = false;
- if((e.RowIndex == fieldslist.NewRowIndex) ||
- frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, true, CultureInfo.InvariantCulture))
- fieldslist.BeginEdit(false);
+ if((e.RowIndex == fieldslist.NewRowIndex) ||
+ frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, StringComparison.OrdinalIgnoreCase))
+ fieldslist.BeginEdit(false);
else
fieldslist.BeginEdit(true);
}
@@ -468,12 +468,13 @@ namespace CodeImp.DoomBuilder.Controls
// Select the value of this field (for DropDownList style combo)
foreach(EnumItem i in enumscombo.Items)
{
- // Matches?
- if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), true, CultureInfo.InvariantCulture) == 0)
- {
+ // Matches?
+ if (string.Compare(i.Title, frow.TypeHandler.GetStringValue(), StringComparison.OrdinalIgnoreCase) == 0)
+ {
// Select this item
enumscombo.SelectedItem = i;
- }
+ break; //mxd
+ }
}
// Put the display text in the text (for DropDown style combo)
diff --git a/Source/Core/Controls/ScriptDocumentTab.cs b/Source/Core/Controls/ScriptDocumentTab.cs
index 4542e81..e6c2036 100644
--- a/Source/Core/Controls/ScriptDocumentTab.cs
+++ b/Source/Core/Controls/ScriptDocumentTab.cs
@@ -338,7 +338,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
- }
+
+ parser.Dispose();
+ }
//mxd
private void UpdateNavigatorModeldef(MemoryStream stream)
@@ -356,7 +358,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
- }
+
+ parser.Dispose();
+ }
//mxd
private void UpdateNavigatorAcs(MemoryStream stream)
@@ -376,7 +380,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
- }
+
+ parser.Dispose();
+ }
//mxd
internal ScriptType VerifyScriptType()
@@ -393,7 +399,8 @@ namespace CodeImp.DoomBuilder.Controls
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
- return ScriptType.UNKNOWN;
+ parser.Dispose();
+ return ScriptType.UNKNOWN;
}
//mxd
diff --git a/Source/Core/Controls/ScriptEditorControl.cs b/Source/Core/Controls/ScriptEditorControl.cs
index 4936705..f6372e7 100644
--- a/Source/Core/Controls/ScriptEditorControl.cs
+++ b/Source/Core/Controls/ScriptEditorControl.cs
@@ -295,7 +295,7 @@ namespace CodeImp.DoomBuilder.Controls
foreach (string rn in resnames)
{
// Found one?
- if (rn.EndsWith(LEXERS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
+ if (rn.EndsWith(LEXERS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream lexersdata = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/Controls/ScriptEditorPanel.cs b/Source/Core/Controls/ScriptEditorPanel.cs
index f105166..aff6ab4 100644
--- a/Source/Core/Controls/ScriptEditorPanel.cs
+++ b/Source/Core/Controls/ScriptEditorPanel.cs
@@ -139,7 +139,7 @@ namespace CodeImp.DoomBuilder.Controls
tabs.TabPages.Add(t);
}
}
- if (General.Map.FilePathName != "")
+ if (!String.IsNullOrEmpty(General.Map.FilePathName))
{
WAD file = new WAD(General.Map.FilePathName);
List lumps = file.Lumps;
@@ -630,7 +630,7 @@ namespace CodeImp.DoomBuilder.Controls
foreach (string ext in cfg.Extensions)
{
// Use this configuration if the extension matches
- if (filename.EndsWith("." + ext, true, CultureInfo.InvariantCulture))
+ if (filename.EndsWith("." + ext, StringComparison.OrdinalIgnoreCase))
{
foundconfig = cfg;
break;
diff --git a/Source/Core/Controls/ScriptFileDocumentTab.cs b/Source/Core/Controls/ScriptFileDocumentTab.cs
index ed46d29..bd979c3 100644
--- a/Source/Core/Controls/ScriptFileDocumentTab.cs
+++ b/Source/Core/Controls/ScriptFileDocumentTab.cs
@@ -126,8 +126,8 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
- //mxd. Update script navigator
- UpdateNavigator();
+ //mxd. Update script navigator
+ UpdateNavigator();
// Feed errors to panel
panel.ShowErrors(errors);
@@ -256,9 +256,10 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
+ parser.Dispose();
- // Update script navigator
- UpdateNavigator();
+ // Update script navigator
+ UpdateNavigator();
// Feed errors to panel
panel.ShowErrors(errors);
diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs
index 654836d..f014d0c 100644
--- a/Source/Core/Data/DataManager.cs
+++ b/Source/Core/Data/DataManager.cs
@@ -1855,7 +1855,7 @@ namespace CodeImp.DoomBuilder.Data
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if(parser.HasError)
{
- decorate.LogError();
+ parser.LogError();
return;
}
}
@@ -2011,8 +2011,9 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
- foreach(KeyValuePair e in modeldefentriesbyname)
+ foreach (KeyValuePair e in modeldefentriesbyname)
{
if(actorsbyclass.ContainsKey(e.Key))
modeldefentries[actorsbyclass[e.Key]] = modeldefentriesbyname[e.Key];
@@ -2098,9 +2099,10 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
- //get voxel models
- foreach(KeyValuePair group in voxelNames)
+ //get voxel models
+ foreach (KeyValuePair group in voxelNames)
{
if(processed.ContainsKey(group.Key)) continue;
foreach(KeyValuePair> sc in sprites)
@@ -2160,6 +2162,8 @@ namespace CodeImp.DoomBuilder.Data
// And skyboxes
skyboxes = parser.Skyboxes;
+
+ parser.Dispose();
}
//mxd. This updates mapinfo class only
@@ -2207,6 +2211,7 @@ namespace CodeImp.DoomBuilder.Data
spawnnums = new Dictionary();
doomednums = new Dictionary();
+ parser.Dispose();
}
else
{
@@ -2246,6 +2251,7 @@ namespace CodeImp.DoomBuilder.Data
doomednums = new Dictionary();
mapinfo = new MapInfo();
}
+ parser.Dispose();
}
currentreader = null;
}
@@ -2281,7 +2287,8 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
reverbs = parser.GetReverbs();
- }
+ parser.Dispose();
+ }
//mxd. This loads SNDSEQ
private void LoadSndSeq()
@@ -2309,7 +2316,8 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
soundsequences = parser.GetSoundSequences();
- }
+ parser.Dispose();
+ }
//mxd. This loads cameratextures from ANIMDEFS
private void LoadAnimdefs()
@@ -2376,7 +2384,8 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
- }
+ parser.Dispose();
+ }
//mxd
internal Stream LoadFile(string name)
diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs
index 5dd1bbd..fbace60 100644
--- a/Source/Core/Data/ImageData.cs
+++ b/Source/Core/Data/ImageData.cs
@@ -33,7 +33,7 @@ using SlimDX.Direct3D9;
namespace CodeImp.DoomBuilder.Data
{
- public abstract unsafe class ImageData
+ public abstract unsafe class ImageData : IDisposable
{
#region ================== Constants
diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs
index 85c5f5a..9ed2a6f 100644
--- a/Source/Core/Data/WADReader.cs
+++ b/Source/Core/Data/WADReader.cs
@@ -410,7 +410,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
- }
+
+ parser.Dispose();
+ }
// This loads a set of textures
public static void LoadTextureSet(string sourcename, Stream texturedata, ref List images, PatchNames pnames)
@@ -640,7 +642,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
- }
+
+ parser.Dispose();
+ }
// This finds and returns a patch stream
public override Stream GetFlatData(string pname, bool longname)
@@ -702,7 +706,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
- }
+
+ parser.Dispose();
+ }
// This finds and returns a sprite stream
public override Stream GetSpriteData(string pname)
diff --git a/Source/Core/Editing/EditMode.cs b/Source/Core/Editing/EditMode.cs
index 31825fc..4bb0359 100644
--- a/Source/Core/Editing/EditMode.cs
+++ b/Source/Core/Editing/EditMode.cs
@@ -78,12 +78,13 @@ namespace CodeImp.DoomBuilder.Editing
object[] attrs = this.GetType().GetCustomAttributes(true);
foreach(object a in attrs)
{
- if(a is EditModeAttribute)
- {
- attributes = (EditModeAttribute)a;
- break;
- }
- }
+ EditModeAttribute attribute = a as EditModeAttribute;
+ if (attribute != null)
+ {
+ attributes = attribute;
+ break;
+ }
+ }
// No attributes found?
if(attributes == null) throw new Exception("Editing mode \"" + this.GetType().Name + "\" is missing EditMode attributes!");
diff --git a/Source/Core/Editing/EditModeAttribute.cs b/Source/Core/Editing/EditModeAttribute.cs
index 662a2a9..bb7fa68 100644
--- a/Source/Core/Editing/EditModeAttribute.cs
+++ b/Source/Core/Editing/EditModeAttribute.cs
@@ -27,7 +27,7 @@ namespace CodeImp.DoomBuilder.Editing
/// Allows automatic binding with an action and a button on the toolbar/menu.
///
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
- public class EditModeAttribute : Attribute
+ public sealed class EditModeAttribute : Attribute
{
#region ================== Variables
diff --git a/Source/Core/Editing/UndoManager.cs b/Source/Core/Editing/UndoManager.cs
index 3d22060..c02d5fb 100644
--- a/Source/Core/Editing/UndoManager.cs
+++ b/Source/Core/Editing/UndoManager.cs
@@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Actions;
namespace CodeImp.DoomBuilder.Editing
{
- public class UndoManager
+ public class UndoManager : IDisposable
{
#region ================== Constants
@@ -181,7 +181,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Disposer
- internal void Dispose()
+ public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -198,9 +198,21 @@ namespace CodeImp.DoomBuilder.Editing
ClearUndos();
ClearRedos();
General.WriteLogLine("All undo and redo levels cleared.");
-
- // Done
- isdisposed = true;
+
+ //mxd
+ if (ss != null)
+ {
+ ss.Dispose();
+ ss = null;
+ }
+ if (stream != null)
+ {
+ stream.Dispose();
+ stream = null;
+ }
+
+ // Done
+ isdisposed = true;
}
}
@@ -367,12 +379,12 @@ namespace CodeImp.DoomBuilder.Editing
}
// This outputs record info, if desired
- private void LogRecordInfo(string info)
+ /*private void LogRecordInfo(string info)
{
#if DEBUG
//General.WriteLogLine(info);
#endif
- }
+ }*/
// This plays back a stream in reverse
private void PlaybackStream(MemoryStream pstream)
@@ -432,8 +444,12 @@ namespace CodeImp.DoomBuilder.Editing
numcmds--;
}
}
-
- General.Map.Map.AutoRemove = true;
+
+ //mxd
+ ds.End();
+ ds.Dispose();
+
+ General.Map.Map.AutoRemove = true;
}
#endregion
diff --git a/Source/Core/Editing/UndoSnapshot.cs b/Source/Core/Editing/UndoSnapshot.cs
index d994ba4..8c123cc 100644
--- a/Source/Core/Editing/UndoSnapshot.cs
+++ b/Source/Core/Editing/UndoSnapshot.cs
@@ -16,6 +16,7 @@
#region ================== Namespaces
+using System;
using System.IO;
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
@@ -23,14 +24,14 @@ using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
namespace CodeImp.DoomBuilder.Editing
{
- public class UndoSnapshot
+ public class UndoSnapshot : IDisposable
{
#region ================== Variables
private MemoryStream recstream;
private string filename;
private string description;
- private int ticketid; // For safe withdrawing
+ private readonly int ticketid; // For safe withdrawing
private volatile bool storeondisk;
private volatile bool isondisk;
private bool isdisposed;
@@ -70,7 +71,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Disposer
- internal void Dispose()
+ public void Dispose()
{
lock(this)
{
diff --git a/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs b/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
index c5babdc..466790f 100644
--- a/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
+++ b/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
@@ -95,13 +95,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
public void ApplyTo(UniFields fields, int min, int max, float oldValue1, float oldValue2)
{
- if(value1.Text != string.Empty)
- UniFields.SetFloat(fields, field1, General.Clamp(value1.GetResultFloat(oldValue1), min, max), defaultValue);
+ if (!string.IsNullOrEmpty(value1.Text))
+ UniFields.SetFloat(fields, field1, General.Clamp(value1.GetResultFloat(oldValue1), min, max), defaultValue);
else
UniFields.SetFloat(fields, field1, oldValue1, defaultValue);
- if(value2.Text != string.Empty)
- UniFields.SetFloat(fields, field2, General.Clamp(value2.GetResultFloat(oldValue2), min, max), defaultValue);
+ if (!string.IsNullOrEmpty(value2.Text))
+ UniFields.SetFloat(fields, field2, General.Clamp(value2.GetResultFloat(oldValue2), min, max), defaultValue);
else
UniFields.SetFloat(fields, field2, oldValue2, defaultValue);
}
diff --git a/Source/Core/GZBuilder/Data/EngineInfo.cs b/Source/Core/GZBuilder/Data/EngineInfo.cs
index 6d742d0..55d73a8 100644
--- a/Source/Core/GZBuilder/Data/EngineInfo.cs
+++ b/Source/Core/GZBuilder/Data/EngineInfo.cs
@@ -4,9 +4,12 @@ using System.IO;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
- public class EngineInfo
+ public class EngineInfo : IDisposable
{
- public const string DEFAULT_ENGINE_NAME = "Engine with no name";
+ // Disposing
+ private bool isdisposed;
+
+ public const string DEFAULT_ENGINE_NAME = "Engine with no name";
private string testprogramname;
public string TestProgramName { get { return testprogramname; } set { testprogramname = value; CheckProgramName(); } }
@@ -64,5 +67,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
icon = new Bitmap(16, 16);
}
}
- }
+
+ public void Dispose()
+ {
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ // Clean up
+ icon.Dispose();
+
+ // Done
+ isdisposed = true;
+ }
+ }
+ }
}
diff --git a/Source/Core/GZBuilder/GZGeneral.cs b/Source/Core/GZBuilder/GZGeneral.cs
index d976c9d..d53472f 100644
--- a/Source/Core/GZBuilder/GZGeneral.cs
+++ b/Source/Core/GZBuilder/GZGeneral.cs
@@ -1,9 +1,5 @@
#region ================== Namespaces
-using CodeImp.DoomBuilder.Actions;
-using CodeImp.DoomBuilder.Config;
-using CodeImp.DoomBuilder.Editing;
-using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.GZBuilder.Data;
#endregion
@@ -29,161 +25,5 @@ namespace CodeImp.DoomBuilder.GZBuilder
#endregion
- #region ================== Methods
-
- public static void Init()
- {
- //bind actions
- General.Actions.BindMethods(typeof(GZGeneral));
- }
-
- #endregion
-
- #region ================== Actions
-
- [BeginAction("gztogglemodels")]
- private static void ToggleModelsRenderingMode()
- {
- switch(General.Settings.GZDrawModelsMode)
- {
- case ModelRenderMode.NONE:
- General.Settings.GZDrawModelsMode = ModelRenderMode.SELECTION;
- General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: SELECTION ONLY");
- break;
-
- case ModelRenderMode.SELECTION:
- General.Settings.GZDrawModelsMode = ModelRenderMode.ACTIVE_THINGS_FILTER;
- General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ACTIVE THINGS FILTER ONLY");
- break;
-
- case ModelRenderMode.ACTIVE_THINGS_FILTER:
- General.Settings.GZDrawModelsMode = ModelRenderMode.ALL;
- General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ALL");
- break;
-
- case ModelRenderMode.ALL:
- General.Settings.GZDrawModelsMode = ModelRenderMode.NONE;
- General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: NONE");
- break;
- }
-
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztogglelights")]
- private static void ToggleLightsRenderingMode()
- {
- if (General.Editing.Mode is ClassicMode)
- {
- switch (General.Settings.GZDrawLightsMode)
- {
- case LightRenderMode.NONE:
- General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
- General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
- break;
-
- default:
- General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
- General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
- break;
- }
- }
- else
- {
- switch (General.Settings.GZDrawLightsMode)
- {
- case LightRenderMode.NONE:
- General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
- General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
- break;
-
- case LightRenderMode.ALL:
- General.Settings.GZDrawLightsMode = LightRenderMode.ALL_ANIMATED;
- General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ANIMATED");
- break;
-
- case LightRenderMode.ALL_ANIMATED:
- General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
- General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
- break;
- }
- }
-
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztogglefog")]
- private static void ToggleFog()
- {
- General.Settings.GZDrawFog = !General.Settings.GZDrawFog;
- General.MainWindow.DisplayStatus(StatusType.Action, "Fog rendering is " + (General.Settings.GZDrawFog ? "ENABLED" : "DISABLED"));
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztogglesky")]
- private static void ToggleSky()
- {
- General.Settings.GZDrawSky = !General.Settings.GZDrawSky;
- General.MainWindow.DisplayStatus(StatusType.Action, "Sky rendering is " + (General.Settings.GZDrawSky ? "ENABLED" : "DISABLED"));
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztogglefx")]
- private static void ToggleFx()
- {
- int on = 0;
- on += General.Settings.GZDrawFog ? 1 : -1;
- on += General.Settings.GZDrawSky ? 1 : -1;
- on += General.Settings.GZDrawLightsMode != LightRenderMode.NONE ? 1 : -1;
- on += General.Settings.GZDrawModelsMode != ModelRenderMode.NONE ? 1 : -1;
-
- bool enable = (on < 0);
-
- General.Settings.GZDrawFog = enable;
- General.Settings.GZDrawSky = enable;
- General.Settings.GZDrawLightsMode = (enable ? LightRenderMode.ALL : LightRenderMode.NONE);
- General.Settings.GZDrawModelsMode = (enable ? ModelRenderMode.ALL : ModelRenderMode.NONE);
- General.MainWindow.DisplayStatus(StatusType.Action, "Advanced effects are " + (enable ? "ENABLED" : "DISABLED") );
-
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztoggleeventlines")]
- private static void ToggleEventLines()
- {
- General.Settings.GZShowEventLines = !General.Settings.GZShowEventLines;
- General.MainWindow.DisplayStatus(StatusType.Action, "Event lines are " + (General.Settings.GZShowEventLines ? "ENABLED" : "DISABLED"));
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- [BeginAction("gztogglevisualvertices")]
- private static void ToggleVisualVertices()
- {
- General.Settings.GZShowVisualVertices = !General.Settings.GZShowVisualVertices;
- General.MainWindow.DisplayStatus(StatusType.Action, "Visual vertices are " + (General.Settings.GZShowVisualVertices ? "ENABLED" : "DISABLED"));
- General.MainWindow.RedrawDisplay();
- General.MainWindow.UpdateGZDoomPanel();
- }
-
- //main menu actions
- [BeginAction("gzreloadmodeldef")]
- private static void ReloadModeldef()
- {
- if(General.Map != null) General.Map.Data.ReloadModeldef();
- }
-
- [BeginAction("gzreloadgldefs")]
- private static void ReloadGldefs()
- {
- if(General.Map != null) General.Map.Data.ReloadGldefs();
- }
-
- #endregion
}
}
\ No newline at end of file
diff --git a/Source/Core/GZBuilder/Rendering/VisualVertexHandle.cs b/Source/Core/GZBuilder/Rendering/VisualVertexHandle.cs
index eac7e3d..021ff35 100644
--- a/Source/Core/GZBuilder/Rendering/VisualVertexHandle.cs
+++ b/Source/Core/GZBuilder/Rendering/VisualVertexHandle.cs
@@ -43,7 +43,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
if(!isdisposed)
{
if(upper != null) upper.Dispose();
+ upper = null;
if(lower != null) lower.Dispose();
+ lower = null;
// Unregister resource
General.Map.Graphics.UnregisterResource(this);
@@ -109,8 +111,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
{
// Trash geometry buffers
if(upper != null) upper.Dispose();
- if(lower != null) lower.Dispose();
- upper = null;
+ upper = null;
+ if (lower != null) lower.Dispose();
lower = null;
}
diff --git a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
index 7a45aa8..91faba6 100644
--- a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
+++ b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
@@ -22,10 +22,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
logPath = Path.Combine(General.SettingsPath, @"GZCrash.txt");
Exception ex = (Exception)e.ExceptionObject;
errorDescription.Text = "Error in " + ex.Source + ":";
- using(StreamWriter sw = File.CreateText(logPath))
+ string sysinfo = GetSystemInfo();
+ using (StreamWriter sw = File.CreateText(logPath))
{
- sw.Write(GetExceptionDescription(ex));
- }
+ sw.Write(sysinfo + GetExceptionDescription(ex));
+ }
errorMessage.Text = ex.Message + Environment.NewLine + ex.StackTrace;
cannotContinue = true; //cannot recover from this...
diff --git a/Source/Core/General/Clock.cs b/Source/Core/General/Clock.cs
index 8b848fd..85b3931 100644
--- a/Source/Core/General/Clock.cs
+++ b/Source/Core/General/Clock.cs
@@ -18,7 +18,7 @@ using SlimDX;
namespace CodeImp.DoomBuilder
{
- public class Clock
+ public static class Clock
{
// This queries the system for the current time
public static float CurrentTime { get { return Configuration.Timer.ElapsedMilliseconds; } }
diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs
index 1ce06c1..be456e4 100644
--- a/Source/Core/General/General.cs
+++ b/Source/Core/General/General.cs
@@ -128,30 +128,16 @@ namespace CodeImp.DoomBuilder
private const string SCREENSHOTS_DIR = "Screenshots"; //mxd
private const string SNIPPETS_DIR = "Snippets"; //mxd
private const string MAP_RESTORE_DIR = "Restore"; //mxd
- private const string SETUP_DIR = "Setup";
private const string SPRITES_DIR = "Sprites";
private const string TEXTURES_DIR = "Textures"; //mxd
private const string HELP_FILE = "Refmanual.chm";
- // SCROLLINFO structure
- /*internal struct ScrollInfo
- {
- public int size; // size of this structure
- public uint mask; // combination of SIF_ constants
- public int min; // minimum scrolling position
- public int max; // maximum scrolling position
- public uint page; // page size (scroll bar uses this value to determine the appropriate size of the proportional scroll box)
- public int pos; // position of the scroll box
- public int trackpos; // immediate position of a scroll box that the user is dragging
- }*/
-
#endregion
#region ================== Variables
// Files and Folders
private static string apppath;
- private static string setuppath;
private static string settingspath;
private static string restorepath; //mxd
private static string logfile;
@@ -176,7 +162,6 @@ namespace CodeImp.DoomBuilder
private static PluginManager plugins;
private static ColorCollection colors;
private static TypesManager types;
- private static Clock clock;
private static ErrorLogger errorlogger;
//private static Mutex appmutex;
@@ -235,7 +220,6 @@ namespace CodeImp.DoomBuilder
public static ActionManager Actions { get { return actions; } }
public static HintsManager Hints { get { return hints; } } //mxd
internal static PluginManager Plugins { get { return plugins; } }
- public static Clock Clock { get { return clock; } }
public static bool DebugBuild { get { return debugbuild; } }
internal static TypesManager Types { get { return types; } }
public static string AutoLoadFile { get { return autoloadfile; } }
@@ -551,11 +535,12 @@ namespace CodeImp.DoomBuilder
// Enable OS visual styles
Application.EnableVisualStyles();
- Application.DoEvents(); // This must be here to work around a .NET bug
- ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());
-
- // Hook to DLL loading failure event
- AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
+ Application.SetCompatibleTextRenderingDefault(false); //mxd
+ //Application.DoEvents(); // This must be here to work around a .NET bug
+ //ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());
+
+ // Hook to DLL loading failure event
+ AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
// Set current thread name
Thread.CurrentThread.Name = "Main Application";
@@ -576,7 +561,6 @@ namespace CodeImp.DoomBuilder
// Setup directories
temppath = Path.GetTempPath();
- setuppath = Path.Combine(apppath, SETUP_DIR);
settingspath = (portablemode ? apppath : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SETTINGS_DIR)); //mxd
restorepath = Path.Combine(settingspath, MAP_RESTORE_DIR);
configspath = Path.Combine(apppath, GAME_CONFIGS_DIR);
@@ -679,20 +663,12 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Loading color settings...");
colors = new ColorCollection(settings.Config);
- // Create application clock
- General.WriteLogLine("Creating application clock...");
- clock = new Clock();
-
// Create types manager
General.WriteLogLine("Creating types manager...");
types = new TypesManager();
-
- //mxd. init gzdoom builder
- GZBuilder.GZGeneral.Init();
// Do auto map loading when window is delayed
- if(delaymainwindow)
- mainwindow.PerformAutoMapLoading();
+ if(delaymainwindow) mainwindow.PerformAutoMapLoading();
// All done
General.WriteLogLine("Startup done");
@@ -1406,10 +1382,10 @@ namespace CodeImp.DoomBuilder
// Cancel volatile mode, if any
editing.DisengageVolatileMode();
-
- // Check if a wad file is known
- if(map.FilePathName == "")
- {
+
+ // Check if a wad file is known
+ if (string.IsNullOrEmpty(map.FilePathName))
+ {
// Call to SaveMapAs
result = SaveMapAs();
}
diff --git a/Source/Core/General/Launcher.cs b/Source/Core/General/Launcher.cs
index 702b12d..3f659eb 100644
--- a/Source/Core/General/Launcher.cs
+++ b/Source/Core/General/Launcher.cs
@@ -279,12 +279,12 @@ namespace CodeImp.DoomBuilder
{
Cursor oldcursor = Cursor.Current;
- // Check if configuration is OK
- if(General.Map.ConfigSettings.TestProgram == "" || !File.Exists(General.Map.ConfigSettings.TestProgram))
- {
+ // Check if configuration is OK
+ if (string.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram) || !File.Exists(General.Map.ConfigSettings.TestProgram))
+ {
//mxd. Let's be more precise
string message;
- if(General.Map.ConfigSettings.TestProgram == "")
+ if(String.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram))
message = "Your test program is not set for the current game configuration";
else
message = "Current test program has invalid path";
diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs
index af310c2..8dcc933 100644
--- a/Source/Core/General/MapManager.cs
+++ b/Source/Core/General/MapManager.cs
@@ -40,7 +40,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder
{
- public sealed class MapManager
+ public sealed class MapManager : IDisposable
{
#region ================== Constants
@@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder
}
// Disposer
- internal bool Dispose()
+ public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -235,11 +235,7 @@ namespace CodeImp.DoomBuilder
// Done
isdisposed = true;
- return true;
}
-
- // Already closed
- return true;
}
#endregion
@@ -828,8 +824,8 @@ namespace CodeImp.DoomBuilder
}
}
- // Determine original map name
- string origmapname = (options.PreviousName != "" && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
+ // Determine original map name
+ string origmapname = (!string.IsNullOrEmpty(options.PreviousName) && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
string origwadfile = string.Empty; //mxd
try
@@ -877,7 +873,7 @@ namespace CodeImp.DoomBuilder
}
// On Save AS we have to copy the previous file to the new file
- if((purpose == SavePurpose.AsNewFile) && (filepathname != ""))
+ if((purpose == SavePurpose.AsNewFile) && (!String.IsNullOrEmpty(filepathname)))
{
// Copy if original file still exists
if(File.Exists(filepathname)) File.Copy(filepathname, newfilepathname, true);
@@ -1658,12 +1654,158 @@ namespace CodeImp.DoomBuilder
[BeginAction("cleargroup10")]
internal void ClearGroup10() { ClearGroup(9); }
- #endregion
+ #endregion
- #region ================== Script Editing
+ #region ================== [mxd] GZDB actions
- // Show the script editor
- [BeginAction("openscripteditor")]
+ [BeginAction("gztogglemodels")]
+ internal void ToggleModelsRenderingMode()
+ {
+ switch (General.Settings.GZDrawModelsMode)
+ {
+ case ModelRenderMode.NONE:
+ General.Settings.GZDrawModelsMode = ModelRenderMode.SELECTION;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: SELECTION ONLY");
+ break;
+
+ case ModelRenderMode.SELECTION:
+ General.Settings.GZDrawModelsMode = ModelRenderMode.ACTIVE_THINGS_FILTER;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ACTIVE THINGS FILTER ONLY");
+ break;
+
+ case ModelRenderMode.ACTIVE_THINGS_FILTER:
+ General.Settings.GZDrawModelsMode = ModelRenderMode.ALL;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ALL");
+ break;
+
+ case ModelRenderMode.ALL:
+ General.Settings.GZDrawModelsMode = ModelRenderMode.NONE;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: NONE");
+ break;
+ }
+
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztogglelights")]
+ internal void ToggleLightsRenderingMode()
+ {
+ if (General.Editing.Mode is ClassicMode)
+ {
+ switch (General.Settings.GZDrawLightsMode)
+ {
+ case LightRenderMode.NONE:
+ General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
+ break;
+
+ default:
+ General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
+ break;
+ }
+ }
+ else
+ {
+ switch (General.Settings.GZDrawLightsMode)
+ {
+ case LightRenderMode.NONE:
+ General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
+ break;
+
+ case LightRenderMode.ALL:
+ General.Settings.GZDrawLightsMode = LightRenderMode.ALL_ANIMATED;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ANIMATED");
+ break;
+
+ case LightRenderMode.ALL_ANIMATED:
+ General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
+ break;
+ }
+ }
+
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztogglefog")]
+ internal void ToggleFog()
+ {
+ General.Settings.GZDrawFog = !General.Settings.GZDrawFog;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Fog rendering is " + (General.Settings.GZDrawFog ? "ENABLED" : "DISABLED"));
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztogglesky")]
+ internal void ToggleSky()
+ {
+ General.Settings.GZDrawSky = !General.Settings.GZDrawSky;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Sky rendering is " + (General.Settings.GZDrawSky ? "ENABLED" : "DISABLED"));
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztogglefx")]
+ internal void ToggleFx()
+ {
+ int on = 0;
+ on += General.Settings.GZDrawFog ? 1 : -1;
+ on += General.Settings.GZDrawSky ? 1 : -1;
+ on += General.Settings.GZDrawLightsMode != LightRenderMode.NONE ? 1 : -1;
+ on += General.Settings.GZDrawModelsMode != ModelRenderMode.NONE ? 1 : -1;
+
+ bool enable = (on < 0);
+
+ General.Settings.GZDrawFog = enable;
+ General.Settings.GZDrawSky = enable;
+ General.Settings.GZDrawLightsMode = (enable ? LightRenderMode.ALL : LightRenderMode.NONE);
+ General.Settings.GZDrawModelsMode = (enable ? ModelRenderMode.ALL : ModelRenderMode.NONE);
+ General.MainWindow.DisplayStatus(StatusType.Action, "Advanced effects are " + (enable ? "ENABLED" : "DISABLED"));
+
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztoggleeventlines")]
+ internal void ToggleEventLines()
+ {
+ General.Settings.GZShowEventLines = !General.Settings.GZShowEventLines;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Event lines are " + (General.Settings.GZShowEventLines ? "ENABLED" : "DISABLED"));
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gztogglevisualvertices")]
+ internal void ToggleVisualVertices()
+ {
+ General.Settings.GZShowVisualVertices = !General.Settings.GZShowVisualVertices;
+ General.MainWindow.DisplayStatus(StatusType.Action, "Visual vertices are " + (General.Settings.GZShowVisualVertices ? "ENABLED" : "DISABLED"));
+ General.MainWindow.RedrawDisplay();
+ General.MainWindow.UpdateGZDoomPanel();
+ }
+
+ [BeginAction("gzreloadmodeldef")]
+ internal void ReloadModeldef()
+ {
+ data.ReloadModeldef();
+ }
+
+ [BeginAction("gzreloadgldefs")]
+ internal void ReloadGldefs()
+ {
+ data.ReloadGldefs();
+ }
+
+ #endregion
+
+ #region ================== Script Editing
+
+ // Show the script editor
+ [BeginAction("openscripteditor")]
internal void ShowScriptEditor()
{
Cursor.Current = Cursors.WaitCursor;
@@ -2001,7 +2143,9 @@ namespace CodeImp.DoomBuilder
compilererrors.Add(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine));
break;
}
- }
+
+ parser.Dispose();
+ }
}
}
diff --git a/Source/Core/Geometry/EarClipPolygon.cs b/Source/Core/Geometry/EarClipPolygon.cs
index c8cc7f1..c237948 100644
--- a/Source/Core/Geometry/EarClipPolygon.cs
+++ b/Source/Core/Geometry/EarClipPolygon.cs
@@ -24,6 +24,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Geometry
{
+ [Serializable]
public sealed class EarClipPolygon : LinkedList
{
#region ================== Variables
diff --git a/Source/Core/IO/ClipboardStreamWriter.cs b/Source/Core/IO/ClipboardStreamWriter.cs
index 5feb1e0..28ee6f1 100644
--- a/Source/Core/IO/ClipboardStreamWriter.cs
+++ b/Source/Core/IO/ClipboardStreamWriter.cs
@@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/IO/Configuration.cs b/Source/Core/IO/Configuration.cs
index 56843ee..d5008d2 100644
--- a/Source/Core/IO/Configuration.cs
+++ b/Source/Core/IO/Configuration.cs
@@ -443,10 +443,10 @@ namespace CodeImp.DoomBuilder.IO
private bool ValidateKey(string key, string file, int errorline)
{
bool validateresult;
-
- // Check if key is an empty string
- if(key == "")
- {
+
+ // Check if key is an empty string
+ if (string.IsNullOrEmpty(key))
+ {
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_KEYMISSING);
validateresult = false;
@@ -498,10 +498,10 @@ namespace CodeImp.DoomBuilder.IO
private bool ValidateKeyword(string keyword, string file, int errorline)
{
bool validateresult;
-
- // Check if key is an empty string
- if(keyword == "")
- {
+
+ // Check if key is an empty string
+ if (string.IsNullOrEmpty(keyword))
+ {
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_ASSIGNINVALID);
validateresult = false;
diff --git a/Source/Core/IO/DeserializerStream.cs b/Source/Core/IO/DeserializerStream.cs
index 9c571ae..9c46eca 100644
--- a/Source/Core/IO/DeserializerStream.cs
+++ b/Source/Core/IO/DeserializerStream.cs
@@ -16,6 +16,7 @@
#region ================== Namespaces
+using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Geometry;
using System.IO;
@@ -24,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- internal sealed class DeserializerStream : IReadWriteStream
+ internal sealed class DeserializerStream : IReadWriteStream, IDisposable
{
#region ================== Constants
@@ -33,15 +34,16 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Variables
private Stream stream;
- private BinaryReader reader;
+ private readonly BinaryReader reader;
private string[] stringstable;
private int stringtablepos;
+ private bool isdisposed; //mxd
- #endregion
+ #endregion
- #region ================== Properties
+ #region ================== Properties
- public bool IsWriting { get { return false; } }
+ public bool IsWriting { get { return false; } }
public int EndPosition { get { return stringtablepos; } }
@@ -57,12 +59,29 @@ namespace CodeImp.DoomBuilder.IO
this.reader = new BinaryReader(stream);
}
- #endregion
+ //mxd
+ public void Dispose()
+ {
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ if (reader != null) reader.Close();
+ if (stream != null)
+ {
+ stream.Dispose();
+ stream = null;
+ }
- #region ================== Methods
+ isdisposed = true;
+ }
+ }
- // Management
- public void Begin()
+ #endregion
+
+ #region ================== Methods
+
+ // Management
+ public void Begin()
{
// First 4 bytes are reserved for the offset of the strings table
stringtablepos = reader.ReadInt32();
diff --git a/Source/Core/IO/Lump.cs b/Source/Core/IO/Lump.cs
index e41462d..82aaf81 100644
--- a/Source/Core/IO/Lump.cs
+++ b/Source/Core/IO/Lump.cs
@@ -25,7 +25,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.IO
{
- public class Lump
+ public class Lump : IDisposable
{
#region ================== Methods
@@ -40,14 +40,14 @@ namespace CodeImp.DoomBuilder.IO
private WAD owner;
// Data stream
- private ClippedStream stream;
+ private readonly ClippedStream stream;
// Data info
private string name;
private long longname;
private byte[] fixedname;
- private int offset;
- private int length;
+ private readonly int offset;
+ private readonly int length;
// Disposing
private bool isdisposed;
@@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.IO
}
// Disposer
- internal void Dispose()
+ public void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Core/IO/SerializerStream.cs b/Source/Core/IO/SerializerStream.cs
index 6e02f59..dbad509 100644
--- a/Source/Core/IO/SerializerStream.cs
+++ b/Source/Core/IO/SerializerStream.cs
@@ -25,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- internal sealed class SerializerStream : IReadWriteStream
+ internal sealed class SerializerStream : IReadWriteStream, IDisposable
{
#region ================== Constants
@@ -34,14 +34,15 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Variables
//private Stream stream;
- private BinaryWriter writer;
- private Dictionary stringstable;
+ private readonly BinaryWriter writer;
+ private readonly Dictionary stringstable;
+ private bool isdisposed; //mxd
- #endregion
+ #endregion
- #region ================== Properties
+ #region ================== Properties
- public bool IsWriting { get { return true; } }
+ public bool IsWriting { get { return true; } }
#endregion
@@ -56,12 +57,23 @@ namespace CodeImp.DoomBuilder.IO
this.stringstable = new Dictionary(StringComparer.Ordinal);
}
- #endregion
+ //mxd
+ public void Dispose()
+ {
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ if (writer != null) writer.Close();
+ isdisposed = true;
+ }
+ }
- #region ================== Methods
+ #endregion
- // Management
- public void Begin()
+ #region ================== Methods
+
+ // Management
+ public void Begin()
{
// First 4 bytes are reserved for the offset of the strings table
const int offset = 0;
diff --git a/Source/Core/IO/UniversalMapSetIO.cs b/Source/Core/IO/UniversalMapSetIO.cs
index 92d1dba..d5947ff 100644
--- a/Source/Core/IO/UniversalMapSetIO.cs
+++ b/Source/Core/IO/UniversalMapSetIO.cs
@@ -58,7 +58,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/IO/UniversalParser.cs b/Source/Core/IO/UniversalParser.cs
index 5946d42..6a88152 100644
--- a/Source/Core/IO/UniversalParser.cs
+++ b/Source/Core/IO/UniversalParser.cs
@@ -380,7 +380,7 @@ namespace CodeImp.DoomBuilder.IO
{
// Hexadecimal?
string s = val.ToString();
- if((s.Length > 2) && s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
+ if((s.Length > 2) && s.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
// Convert to int
try
diff --git a/Source/Core/IO/UniversalStreamReader.cs b/Source/Core/IO/UniversalStreamReader.cs
index 30b1604..b506246 100644
--- a/Source/Core/IO/UniversalStreamReader.cs
+++ b/Source/Core/IO/UniversalStreamReader.cs
@@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/IO/UniversalStreamWriter.cs b/Source/Core/IO/UniversalStreamWriter.cs
index 786cab4..947520d 100644
--- a/Source/Core/IO/UniversalStreamWriter.cs
+++ b/Source/Core/IO/UniversalStreamWriter.cs
@@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/IO/WAD.cs b/Source/Core/IO/WAD.cs
index 9cc35f4..540a3e5 100644
--- a/Source/Core/IO/WAD.cs
+++ b/Source/Core/IO/WAD.cs
@@ -25,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
- internal class WAD
+ internal class WAD : IDisposable
{
#region ================== Constants
diff --git a/Source/Core/Map/MapOptions.cs b/Source/Core/Map/MapOptions.cs
index 374a2ff..95a96cf 100644
--- a/Source/Core/Map/MapOptions.cs
+++ b/Source/Core/Map/MapOptions.cs
@@ -107,8 +107,8 @@ namespace CodeImp.DoomBuilder.Map
// Change the name, but keep previous name
if(currentname != value)
{
- if(previousname == "") previousname = currentname;
- currentname = value;
+ if (string.IsNullOrEmpty(previousname)) previousname = currentname;
+ currentname = value;
}
}
}
diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs
index 5140763..463280a 100644
--- a/Source/Core/Map/MapSet.cs
+++ b/Source/Core/Map/MapSet.cs
@@ -899,9 +899,10 @@ namespace CodeImp.DoomBuilder.Map
ReadThings(deserializer);
deserializer.End();
+ deserializer.Dispose(); //mxd
- // Make table of sidedef indices
- sidedefindices = new Sidedef[numsidedefs];
+ // Make table of sidedef indices
+ sidedefindices = new Sidedef[numsidedefs];
foreach(Sidedef sd in sidedefs)
sidedefindices[sd.SerializedIndex] = sd;
diff --git a/Source/Core/Map/UniFields.cs b/Source/Core/Map/UniFields.cs
index 636338c..371cc4e 100644
--- a/Source/Core/Map/UniFields.cs
+++ b/Source/Core/Map/UniFields.cs
@@ -11,6 +11,7 @@ namespace CodeImp.DoomBuilder.Map
///
/// List of universal fields and their values.
///
+ [Serializable]
public class UniFields : Dictionary
{
#region ================== Variables
diff --git a/Source/Core/Plugins/Plugin.cs b/Source/Core/Plugins/Plugin.cs
index 54e25c4..3c54801 100644
--- a/Source/Core/Plugins/Plugin.cs
+++ b/Source/Core/Plugins/Plugin.cs
@@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder.Plugins
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(resourcename, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(resourcename, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
return asm.GetManifestResourceStream(rn);
diff --git a/Source/Core/Rendering/ColorSetting.cs b/Source/Core/Rendering/ColorSetting.cs
index d044565..dc5e7ed 100644
--- a/Source/Core/Rendering/ColorSetting.cs
+++ b/Source/Core/Rendering/ColorSetting.cs
@@ -13,7 +13,7 @@
*/
#endregion
-
+/*
#region ================== Namespaces
using System;
@@ -88,3 +88,4 @@ namespace CodeImp.DoomBuilder.Rendering
#endregion
}
}
+*/
\ No newline at end of file
diff --git a/Source/Core/Rendering/D3DDevice.cs b/Source/Core/Rendering/D3DDevice.cs
index a0be74c..f819742 100644
--- a/Source/Core/Rendering/D3DDevice.cs
+++ b/Source/Core/Rendering/D3DDevice.cs
@@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Rendering
{
- internal class D3DDevice
+ internal class D3DDevice : IDisposable
{
#region ================== Constants
@@ -53,8 +53,8 @@ namespace CodeImp.DoomBuilder.Rendering
private Capabilities devicecaps;
private Device device;
private Viewport viewport;
- private Dictionary resources;
- private ShaderManager shaders;
+ private readonly HashSet resources;
+ private ShaderManager shaders;
private Surface backbuffer;
private Surface depthbuffer;
private TextFont font;
@@ -90,27 +90,31 @@ namespace CodeImp.DoomBuilder.Rendering
// Set render target
this.rendertarget = rendertarget;
- // Create resources list
- resources = new Dictionary();
-
- // We have no destructor
- GC.SuppressFinalize(this);
+ // Create resources list
+ resources = new HashSet();
+
+ // We have no destructor
+ GC.SuppressFinalize(this);
}
// Disposer
- internal void Dispose()
+ public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
- foreach(ID3DResource res in resources.Values) res.UnloadResource();
+ foreach(ID3DResource res in resources) res.UnloadResource();
if(shaders != null) shaders.Dispose();
rendertarget = null;
if(backbuffer != null) backbuffer.Dispose();
if(depthbuffer != null) depthbuffer.Dispose();
- if(device != null) device.Dispose();
- if(font != null) font.Dispose();
+ if (device != null)
+ {
+ device.Reset(new PresentParameters()); //mxd. Some video memory is not freed without this line if Visual mode was visited
+ device.Dispose();
+ }
+ if (font != null) font.Dispose();
if(fonttexture != null) fonttexture.Dispose();
isrendering = false; //mxd
@@ -325,7 +329,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal void RegisterResource(ID3DResource res)
{
// Add resource
- resources.Add(res, res);
+ resources.Add(res);
}
// This unregisters a resource
@@ -339,7 +343,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal bool Reset()
{
// Unload all Direct3D resources
- foreach(ID3DResource res in resources.Values) res.UnloadResource();
+ foreach(ID3DResource res in resources) res.UnloadResource();
// Lose backbuffers
if(backbuffer != null) backbuffer.Dispose();
@@ -378,7 +382,7 @@ namespace CodeImp.DoomBuilder.Rendering
viewport = device.Viewport;
// Reload all Direct3D resources
- foreach(ID3DResource res in resources.Values) res.ReloadResource();
+ foreach(ID3DResource res in resources) res.ReloadResource();
// Re-apply settings
SetupSettings();
diff --git a/Source/Core/Rendering/D3DShader.cs b/Source/Core/Rendering/D3DShader.cs
index 3bfc465..d381213 100644
--- a/Source/Core/Rendering/D3DShader.cs
+++ b/Source/Core/Rendering/D3DShader.cs
@@ -24,7 +24,7 @@ using SlimDX.Direct3D9;
namespace CodeImp.DoomBuilder.Rendering
{
- internal abstract class D3DShader
+ internal abstract class D3DShader : IDisposable
{
#region ================== Constants
diff --git a/Source/Core/Rendering/Renderer.cs b/Source/Core/Rendering/Renderer.cs
index 2bfe618..c50ef49 100644
--- a/Source/Core/Rendering/Renderer.cs
+++ b/Source/Core/Rendering/Renderer.cs
@@ -25,7 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.Rendering
{
- internal abstract class Renderer : ID3DResource
+ internal abstract class Renderer : ID3DResource, IDisposable
{
#region ================== Constants
@@ -66,7 +66,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
- internal virtual void Dispose()
+ public virtual void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs
index b7728b5..de3f23d 100644
--- a/Source/Core/Rendering/Renderer2D.cs
+++ b/Source/Core/Rendering/Renderer2D.cs
@@ -161,7 +161,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
- internal override void Dispose()
+ public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs
index 6328c7a..407e2f4 100644
--- a/Source/Core/Rendering/Renderer3D.cs
+++ b/Source/Core/Rendering/Renderer3D.cs
@@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
- internal override void Dispose()
+ public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
diff --git a/Source/Core/Rendering/TextFont.cs b/Source/Core/Rendering/TextFont.cs
index dad5df3..afc1c91 100644
--- a/Source/Core/Rendering/TextFont.cs
+++ b/Source/Core/Rendering/TextFont.cs
@@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(string rn in resnames)
{
// Found it?
- if(rn.EndsWith(FONT_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
+ if(rn.EndsWith(FONT_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream fontdata = General.ThisAssembly.GetManifestResourceStream(rn);
diff --git a/Source/Core/Rendering/World3DShader.cs b/Source/Core/Rendering/World3DShader.cs
index 2d3141a..5b786c1 100644
--- a/Source/Core/Rendering/World3DShader.cs
+++ b/Source/Core/Rendering/World3DShader.cs
@@ -39,21 +39,16 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
private readonly EffectHandle vertexColorHadle;
- //lights
- private readonly EffectHandle lightPositionAndRadiusHandle;
- private readonly EffectHandle lightColorHandle;
- private readonly EffectHandle world;
- //fog
- private readonly EffectHandle camPosHandle;
- //used in ModelReader
- private readonly VertexElement[] vertexElements;
+ private readonly EffectHandle lightPositionAndRadiusHandle; //lights
+ private readonly EffectHandle lightColorHandle;
+ private readonly EffectHandle world;
+ private readonly EffectHandle camPosHandle; //used for fog rendering
-
- #endregion
+ #endregion
- #region ================== Properties
+ #region ================== Properties
- private Matrix wwp;
+ private Matrix wwp;
public Matrix WorldViewProj
{
set
@@ -190,7 +185,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Initialize world vertex declaration
- vertexElements = new[]
+ VertexElement[] ve = new[]
{
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
@@ -199,7 +194,7 @@ namespace CodeImp.DoomBuilder.Rendering
VertexElement.VertexDeclarationEnd
};
- vertexdecl = new VertexDeclaration(General.Map.Graphics.Device, vertexElements);
+ vertexdecl = new VertexDeclaration(General.Map.Graphics.Device, ve);
// We have no destructor
GC.SuppressFinalize(this);
diff --git a/Source/Core/SRB2/LuaObjectParser.cs b/Source/Core/SRB2/LuaObjectParser.cs
index 6a4cb64..2b3e6d2 100644
--- a/Source/Core/SRB2/LuaObjectParser.cs
+++ b/Source/Core/SRB2/LuaObjectParser.cs
@@ -55,13 +55,17 @@ namespace CodeImp.DoomBuilder.SRB2
}
// Disposer
- public void Dispose()
+ override public void Dispose()
{
- objects = null;
- /*states = null;
- objectfreeslots = null;
- statefreeslots = null;
- spritefreeslots = null;*/
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ objects = null;
+ /*states = null;
+ objectfreeslots = null;
+ statefreeslots = null;
+ spritefreeslots = null;*/
+ }
}
#endregion
diff --git a/Source/Core/SRB2/SOCObjectParser.cs b/Source/Core/SRB2/SOCObjectParser.cs
index 16324d5..4b8902f 100644
--- a/Source/Core/SRB2/SOCObjectParser.cs
+++ b/Source/Core/SRB2/SOCObjectParser.cs
@@ -57,13 +57,17 @@ namespace CodeImp.DoomBuilder.SRB2
}
// Disposer
- public void Dispose()
+ override public void Dispose()
{
- objects = null;
- /*states = null;
- objectfreeslots = null;
- statefreeslots = null;
- spritefreeslots = null;*/
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ objects = null;
+ /*states = null;
+ objectfreeslots = null;
+ statefreeslots = null;
+ spritefreeslots = null;*/
+ }
}
#endregion
diff --git a/Source/Core/Types/TypeHandlerAttribute.cs b/Source/Core/Types/TypeHandlerAttribute.cs
index 3e1243a..b190628 100644
--- a/Source/Core/Types/TypeHandlerAttribute.cs
+++ b/Source/Core/Types/TypeHandlerAttribute.cs
@@ -22,7 +22,7 @@ using System;
namespace CodeImp.DoomBuilder.Types
{
- public class TypeHandlerAttribute : Attribute
+ public sealed class TypeHandlerAttribute : Attribute
{
#region ================== Constants
diff --git a/Source/Core/VisualModes/VisualSector.cs b/Source/Core/VisualModes/VisualSector.cs
index 4f3c405..1ed8f30 100644
--- a/Source/Core/VisualModes/VisualSector.cs
+++ b/Source/Core/VisualModes/VisualSector.cs
@@ -16,6 +16,7 @@
#region ================== Namespaces
+using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Map;
using SlimDX.Direct3D9;
@@ -26,7 +27,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.VisualModes
{
- public class VisualSector : ID3DResource
+ public class VisualSector : ID3DResource, IDisposable
{
#region ================== Constants
@@ -35,14 +36,14 @@ namespace CodeImp.DoomBuilder.VisualModes
#region ================== Variables
// Geometry
- private List fixedgeometry;
- private List allgeometry;
- private Dictionary> sidedefgeometry;
+ private readonly List fixedgeometry;
+ private readonly List allgeometry;
+ private readonly Dictionary> sidedefgeometry;
private VertexBuffer geobuffer;
private bool updategeo;
// Original sector
- private Sector sector;
+ private readonly Sector sector;
// Disposing
private bool isdisposed;
diff --git a/Source/Core/VisualModes/VisualThing.cs b/Source/Core/VisualModes/VisualThing.cs
index 845da0b..5830ba2 100644
--- a/Source/Core/VisualModes/VisualThing.cs
+++ b/Source/Core/VisualModes/VisualThing.cs
@@ -32,7 +32,7 @@ using Plane = CodeImp.DoomBuilder.Geometry.Plane;
namespace CodeImp.DoomBuilder.VisualModes
{
- public abstract class VisualThing : IVisualPickable, ID3DResource
+ public abstract class VisualThing : IVisualPickable, ID3DResource, IDisposable
{
#region ================== Constants
diff --git a/Source/Core/Windows/FlagsForm.cs b/Source/Core/Windows/FlagsForm.cs
index bf72aa7..6e70d94 100644
--- a/Source/Core/Windows/FlagsForm.cs
+++ b/Source/Core/Windows/FlagsForm.cs
@@ -37,9 +37,9 @@ namespace CodeImp.DoomBuilder.Windows
foreach(KeyValuePair tf in flagdefs)
flags.Add(tf.Value, tf.Key);
- // Parse the value string and check the boxes if necessary
- if(value.Trim() != "")
- {
+ // Parse the value string and check the boxes if necessary
+ if (!string.IsNullOrEmpty(value.Trim()))
+ {
foreach(string s in value.Split(','))
{
string str = s.Trim();
@@ -84,8 +84,8 @@ namespace CodeImp.DoomBuilder.Windows
{
if(lf.Value == c.Text)
{
- if(value != "") value += ",";
- value += lf.Key;
+ if (!string.IsNullOrEmpty(value)) value += ",";
+ value += lf.Key;
}
}
}
diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs
index 5b8b8c0..42a0352 100644
--- a/Source/Core/Windows/MainForm.cs
+++ b/Source/Core/Windows/MainForm.cs
@@ -2480,7 +2480,7 @@ namespace CodeImp.DoomBuilder.Windows
if(item.Tag is string)
{
// Check if the tag doe not already begin with the assembly name
- if(!(item.Tag as string).StartsWith(plugin.Name + "_", StringComparison.InvariantCultureIgnoreCase))
+ if(!(item.Tag as string).StartsWith(plugin.Name + "_", StringComparison.OrdinalIgnoreCase))
{
// Change the tag to a fully qualified action name
item.Tag = plugin.Name.ToLowerInvariant() + "_" + (item.Tag as string);
@@ -2542,8 +2542,8 @@ namespace CodeImp.DoomBuilder.Windows
// Get configuration setting
string filename = General.Settings.ReadSetting("recentfiles.file" + i, "");
- if(filename != "" && File.Exists(filename))
- {
+ if (!string.IsNullOrEmpty(filename) && File.Exists(filename))
+ {
// Set up item
int number = i + 1;
recentitems[i].Text = "&" + number + " " + GetDisplayFilename(filename);
@@ -2568,9 +2568,9 @@ namespace CodeImp.DoomBuilder.Windows
// Go for all items
for(int i = 0; i < recentitems.Length; i++)
{
- // Recent file set?
- if(recentitems[i].Text != "")
- {
+ // Recent file set?
+ if (!string.IsNullOrEmpty(recentitems[i].Text))
+ {
// Save to configuration
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
}
@@ -2611,8 +2611,8 @@ namespace CodeImp.DoomBuilder.Windows
int number = i + 2;
recentitems[i + 1].Text = "&" + number + " " + GetDisplayFilename(recentitems[i].Tag.ToString());
recentitems[i + 1].Tag = recentitems[i].Tag.ToString();
- recentitems[i + 1].Visible = (recentitems[i].Tag.ToString() != "");
- }
+ recentitems[i + 1].Visible = !string.IsNullOrEmpty(recentitems[i].Tag.ToString());
+ }
// Add new file at the top
recentitems[0].Text = "&1 " + GetDisplayFilename(filename);
@@ -3915,30 +3915,21 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
- // Start annoying blinking!
- if(blink)
- {
- if(!blinkTimer.Enabled) blinkTimer.Start();
- }
- else
- {
- blinkTimer.Stop();
- warnsLabel.BackColor = SystemColors.Control;
- }
-
- // Update icon
- if(count > 0)
- {
- warnsLabel.Image = Resources.Warning;
- }
- else
- {
- warnsLabel.Image = Resources.WarningOff;
- warnsLabel.BackColor = SystemColors.Control;
- }
+ // Update icon, start annoying blinking if necessary
+ if (count > 0)
+ {
+ if (blink && !blinkTimer.Enabled) blinkTimer.Start();
+ warnsLabel.Image = Resources.Warning;
+ }
+ else
+ {
+ blinkTimer.Stop();
+ warnsLabel.Image = Resources.WarningOff;
+ warnsLabel.BackColor = SystemColors.Control;
+ }
- // Update errors count
- warnsLabel.Text = count.ToString();
+ // Update errors count
+ warnsLabel.Text = count.ToString();
}
//mxd. Bliks warnings indicator
@@ -3956,7 +3947,8 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void blinkTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
- try
+ if (!blinkTimer.Enabled) return;
+ try
{
this.Invoke(new CallBlink(Blink));
} catch(ObjectDisposedException) { } //la-la-la. We don't care.
diff --git a/Source/Core/Windows/MapOptionsForm.cs b/Source/Core/Windows/MapOptionsForm.cs
index aa54982..703a7fc 100644
--- a/Source/Core/Windows/MapOptionsForm.cs
+++ b/Source/Core/Windows/MapOptionsForm.cs
@@ -185,8 +185,8 @@ namespace CodeImp.DoomBuilder.Windows
// Level name changed and the map exists in a source wad?
if((levelname.Text != options.CurrentName) && (General.Map != null) &&
- (General.Map.FilePathName != "") && File.Exists(General.Map.FilePathName))
- {
+ (!string.IsNullOrEmpty(General.Map.FilePathName)) && File.Exists(General.Map.FilePathName))
+ {
// Open the source wad file to check for conflicting name
WAD sourcewad = new WAD(General.Map.FilePathName, true);
bool conflictingname = (sourcewad.FindLumpIndex(levelname.Text) > -1);
@@ -213,7 +213,7 @@ namespace CodeImp.DoomBuilder.Windows
// we have to warn the user that the map may not be compatible.
// Configuration changed?
- if((options.ConfigFile != "") && (configinfo.Filename != options.ConfigFile))
+ if((!String.IsNullOrEmpty(options.ConfigFile)) && (configinfo.Filename != options.ConfigFile))
{
// Check if the config uses a different IO interface
if(configinfo.Configuration.ReadSetting("formatinterface", "") != General.Map.Config.FormatInterface)
diff --git a/Source/Core/Windows/TanColorTable.cs b/Source/Core/Windows/TanColorTable.cs
index c750200..da8d6fe 100644
--- a/Source/Core/Windows/TanColorTable.cs
+++ b/Source/Core/Windows/TanColorTable.cs
@@ -13,7 +13,7 @@
*/
#endregion
-
+/*
#region ================== Namespaces
using System;
@@ -772,4 +772,4 @@ namespace CodeImp.DoomBuilder.Windows
}
}
-}
\ No newline at end of file
+}*/
\ No newline at end of file
diff --git a/Source/Core/ZDoom/DecorateParser.cs b/Source/Core/ZDoom/DecorateParser.cs
index b1f582d..7a3ccdc 100644
--- a/Source/Core/ZDoom/DecorateParser.cs
+++ b/Source/Core/ZDoom/DecorateParser.cs
@@ -92,14 +92,20 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// Disposer
- public void Dispose()
+ override public void Dispose()
{
- foreach(KeyValuePair a in archivedactors)
- a.Value.Dispose();
-
- actors = null;
- archivedactors = null;
- }
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ foreach (KeyValuePair a in archivedactors)
+ a.Value.Dispose();
+
+ actors = null;
+ archivedactors = null;
+
+ base.Dispose();
+ }
+ }
#endregion
diff --git a/Source/Core/ZDoom/ZDTextParser.cs b/Source/Core/ZDoom/ZDTextParser.cs
index 6cb2539..448860b 100644
--- a/Source/Core/ZDoom/ZDTextParser.cs
+++ b/Source/Core/ZDoom/ZDTextParser.cs
@@ -28,7 +28,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.ZDoom
{
- public abstract class ZDTextParser
+ public abstract class ZDTextParser : IDisposable
{
#region ================== Constants
@@ -55,12 +55,15 @@ namespace CodeImp.DoomBuilder.ZDoom
protected string errordesc;
protected string errorsource;
protected long prevstreamposition; //mxd. Text stream position storted before performing ReadToken.
-
- #endregion
-
- #region ================== Properties
-
- internal Stream DataStream { get { return datastream; } }
+
+ //mxd. Disposing
+ protected bool isdisposed;
+
+ #endregion
+
+ #region ================== Properties
+
+ internal Stream DataStream { get { return datastream; } }
internal BinaryReader DataReader { get { return datareader; } }
public int ErrorLine { get { return errorline; } }
public string ErrorDescription { get { return errordesc; } }
@@ -77,13 +80,30 @@ namespace CodeImp.DoomBuilder.ZDoom
// Initialize
errordesc = null;
}
-
- #endregion
- #region ================== Parsing
+ //mxd
+ public virtual void Dispose()
+ {
+ // Not already disposed?
+ if (!isdisposed)
+ {
+ if (datareader != null) datareader.Close();
+ if (datastream != null)
+ {
+ datastream.Dispose();
+ datastream = null;
+ }
- //mxd. This parses the given decorate stream. Returns false on errors
- public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
+ isdisposed = true;
+ }
+ }
+
+ #endregion
+
+ #region ================== Parsing
+
+ //mxd. This parses the given decorate stream. Returns false on errors
+ public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
{
//mxd. Clear error status?
if(clearerrors) ClearError();
@@ -588,8 +608,8 @@ namespace CodeImp.DoomBuilder.ZDoom
{
foreach(DataReader reader in General.Map.Data.Containers)
{
- if(reader is DirectoryReader && filename.StartsWith(reader.Location.location, true, CultureInfo.InvariantCulture))
- {
+ if (reader is DirectoryReader && filename.StartsWith(reader.Location.location, StringComparison.OrdinalIgnoreCase))
+ {
filename = filename.Substring(reader.Location.location.Length + 1, filename.Length - reader.Location.location.Length - 1);
break;
}
diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
index 1470c28..ffe26f4 100644
--- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs
@@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
bsp = new BSP(BuilderPlug.Me.DontUseNodes);
useblockmap = bsp.IsDeactivated;
- if (useblockmap && bsp.ErrorMessage != "")
+ if (useblockmap && !String.IsNullOrEmpty(bsp.ErrorMessage))
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);
// We have no destructor
@@ -787,7 +787,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
sectordata = new Dictionary(General.Map.Map.Sectors.Count);
thingdata = new Dictionary(General.Map.Map.Things.Count);
- if (bsp.IsDeactivated && bsp.ErrorMessage != "")
+ if (bsp.IsDeactivated && !String.IsNullOrEmpty(bsp.ErrorMessage))
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);
diff --git a/Source/Plugins/StairSectorBuilder/StairSectorBuilderForm.cs b/Source/Plugins/StairSectorBuilder/StairSectorBuilderForm.cs
index 78f39b7..1225acb 100644
--- a/Source/Plugins/StairSectorBuilder/StairSectorBuilderForm.cs
+++ b/Source/Plugins/StairSectorBuilder/StairSectorBuilderForm.cs
@@ -374,7 +374,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
private void numberofsectors_WhenTextChanged(object sender, EventArgs e)
{
- if(numberofsectors.Text == "" || numberofsectors.GetResult(1) == 0) numberofsectors.Text = "1";
+ if(String.IsNullOrEmpty(numberofsectors.Text) || numberofsectors.GetResult(1) == 0) numberofsectors.Text = "1";
ComputeHeights();
DoRedrawDisplay();
}
@@ -635,7 +635,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
int overwrite = -1;
// Prefab name may not be empty
- if(name == "")
+ if(String.IsNullOrEmpty(name))
{
MessageBox.Show(this.Owner, "Please enter a name for the prefab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
diff --git a/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs b/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
index a0aa39f..2ea2ecb 100644
--- a/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
+++ b/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
@@ -1105,10 +1105,10 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
si.ceilingheight = primary.Sector.CeilHeight;
si.floorheight = primary.Sector.FloorHeight;
- if(stairsectorbuilderform.UpperTextureTexture == "")
+ if(String.IsNullOrEmpty(stairsectorbuilderform.UpperTextureTexture))
stairsectorbuilderform.UpperTextureTexture = (secondary == null) ? primary.MiddleTexture : primary.HighTexture;
- if(stairsectorbuilderform.LowerTextureTexture == "")
+ if(String.IsNullOrEmpty(stairsectorbuilderform.LowerTextureTexture))
stairsectorbuilderform.LowerTextureTexture = (secondary == null) ? primary.MiddleTexture : primary.LowTexture;
siout = si;