diff --git a/Build/Scripting/ZDoom_ACS.cfg b/Build/Scripting/ZDoom_ACS.cfg
index 412fbed2..8a830ebd 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 3e6e7b71..f6babaff 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 352598bf..c227681e 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 ef19c901..0e5decc7 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 8f69fade..23d7e8e7 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 f426b36c..71dd218b 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/Actions/MouseInput.cs b/Source/Core/Actions/MouseInput.cs
index 11d916bc..947b06fc 100644
--- a/Source/Core/Actions/MouseInput.cs
+++ b/Source/Core/Actions/MouseInput.cs
@@ -67,12 +67,12 @@ namespace CodeImp.DoomBuilder.Actions
// Aquire device
try { mouse.Acquire(); }
#if DEBUG
- catch (Exception e)
+ catch(Exception e)
{
Console.WriteLine("MouseInput initialization failed: " + e.Message);
}
#else
- catch (Exception) { }
+ catch(Exception) { }
#endif
// We have no destructor
@@ -130,12 +130,12 @@ namespace CodeImp.DoomBuilder.Actions
// Reaquire device
try { mouse.Acquire(); }
#if DEBUG
- catch (Exception e)
+ catch(Exception e)
{
Console.WriteLine("MouseInput process failed: " + e.Message);
}
#else
- catch (Exception) { }
+ catch(Exception) { }
#endif
return new Vector2D();
}
@@ -149,7 +149,7 @@ namespace CodeImp.DoomBuilder.Actions
{
mouse.Acquire();
}
- catch (Exception e)
+ catch(Exception e)
{
Console.WriteLine("MouseInput process failed: " + e.Message);
}
@@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.Actions
{
// Reaquire device
try { mouse.Acquire(); }
- catch (Exception) { }
+ catch(Exception) { }
return new Vector2D();
}
#endif
diff --git a/Source/Core/Config/ConfigurationInfo.cs b/Source/Core/Config/ConfigurationInfo.cs
index 34e6f2af..72d47199 100644
--- a/Source/Core/Config/ConfigurationInfo.cs
+++ b/Source/Core/Config/ConfigurationInfo.cs
@@ -230,6 +230,7 @@ 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/CheckboxArrayControl.cs b/Source/Core/Controls/CheckboxArrayControl.cs
index 5a4abd64..624838f8 100644
--- a/Source/Core/Controls/CheckboxArrayControl.cs
+++ b/Source/Core/Controls/CheckboxArrayControl.cs
@@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Controls
{
if(this.DesignMode)
{
- using (Pen p = new Pen(SystemColors.ControlDark, 1) { DashStyle = DashStyle.Dash })
+ using(Pen p = new Pen(SystemColors.ControlDark, 1) { DashStyle = DashStyle.Dash })
{
e.Graphics.DrawRectangle(p, 0, 0, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1);
}
diff --git a/Source/Core/Controls/CollapsibleSplitContainer.cs b/Source/Core/Controls/CollapsibleSplitContainer.cs
index eb322a6e..83ff9399 100644
--- a/Source/Core/Controls/CollapsibleSplitContainer.cs
+++ b/Source/Core/Controls/CollapsibleSplitContainer.cs
@@ -185,7 +185,7 @@ namespace CodeImp.DoomBuilder.Controls
bounds = new Rectangle(r.X, r.Y + ((r.Height - scaled[115]) / 2), scaled[8], scaled[115]);
// draw the background color for our control image
- using (SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
+ using(SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
{
e.Graphics.FillRectangle(bg, new Rectangle(bounds.X + scaled[1], bounds.Y, scaled[6], scaled[115]));
}
@@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder.Controls
bounds = new Rectangle(r.X + ((r.Width - scaled[115]) / 2), r.Y, scaled[115], scaled[8]);
// draw the background color for our control image
- using (SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
+ using(SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
{
e.Graphics.FillRectangle(bg, new Rectangle(bounds.X, bounds.Y + scaled[1], scaled[115], scaled[6]));
}
diff --git a/Source/Core/Controls/FieldsEditorControl.cs b/Source/Core/Controls/FieldsEditorControl.cs
index a4fc4657..dc30a721 100644
--- a/Source/Core/Controls/FieldsEditorControl.cs
+++ b/Source/Core/Controls/FieldsEditorControl.cs
@@ -383,7 +383,7 @@ namespace CodeImp.DoomBuilder.Controls
fieldslist.CurrentCell.ReadOnly = false;
if((e.RowIndex == fieldslist.NewRowIndex) ||
- frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, true, CultureInfo.InvariantCulture))
+ frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, StringComparison.OrdinalIgnoreCase))
fieldslist.BeginEdit(false);
else
fieldslist.BeginEdit(true);
@@ -469,10 +469,11 @@ namespace CodeImp.DoomBuilder.Controls
foreach(EnumItem i in enumscombo.Items)
{
// Matches?
- if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), true, CultureInfo.InvariantCulture) == 0)
+ if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), StringComparison.OrdinalIgnoreCase) == 0)
{
// Select this item
enumscombo.SelectedItem = i;
+ break; //mxd
}
}
diff --git a/Source/Core/Controls/ScriptDocumentTab.cs b/Source/Core/Controls/ScriptDocumentTab.cs
index bd7b5daf..25b83aa9 100644
--- a/Source/Core/Controls/ScriptDocumentTab.cs
+++ b/Source/Core/Controls/ScriptDocumentTab.cs
@@ -340,6 +340,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
+
+ parser.Dispose();
}
//mxd
@@ -358,6 +360,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
+
+ parser.Dispose();
}
//mxd
@@ -378,6 +382,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
+
+ parser.Dispose();
}
//mxd
@@ -395,6 +401,7 @@ namespace CodeImp.DoomBuilder.Controls
panel.ShowErrors(new List { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
+ parser.Dispose();
return ScriptType.UNKNOWN;
}
diff --git a/Source/Core/Controls/ScriptEditorControl.cs b/Source/Core/Controls/ScriptEditorControl.cs
index 6f5f4ae3..7a4d2ebd 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 45bf19b0..3ddee4da 100644
--- a/Source/Core/Controls/ScriptEditorPanel.cs
+++ b/Source/Core/Controls/ScriptEditorPanel.cs
@@ -578,7 +578,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 698ce69f..10d614ae 100644
--- a/Source/Core/Controls/ScriptFileDocumentTab.cs
+++ b/Source/Core/Controls/ScriptFileDocumentTab.cs
@@ -256,6 +256,7 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
+ parser.Dispose();
// Update script navigator
UpdateNavigator();
diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs
index 134fcef1..ec7d50ff 100644
--- a/Source/Core/Data/DataManager.cs
+++ b/Source/Core/Data/DataManager.cs
@@ -545,7 +545,7 @@ namespace CodeImp.DoomBuilder.Data
textures = null;
flats = null;
sprites = null;
- modeldefentries = null;//mxd
+ modeldefentries = null; //mxd
texturenames = null;
flatnames = null;
imageque = null;
@@ -1769,7 +1769,7 @@ namespace CodeImp.DoomBuilder.Data
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if(parser.HasError)
{
- decorate.LogError();
+ parser.LogError();
return;
}
}
@@ -1925,6 +1925,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
foreach(KeyValuePair e in modeldefentriesbyname)
{
@@ -2012,6 +2013,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
//get voxel models
foreach(KeyValuePair group in voxelNames)
@@ -2074,6 +2076,8 @@ namespace CodeImp.DoomBuilder.Data
// And skyboxes
skyboxes = parser.Skyboxes;
+
+ parser.Dispose();
}
//mxd. This updates mapinfo class only
@@ -2124,6 +2128,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
}
private void ParseFromLocation(ZDTextParser parser, string location, bool clearerrors)
@@ -2157,6 +2162,7 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
reverbs = parser.GetReverbs();
+ parser.Dispose();
}
//mxd. This loads SNDSEQ
@@ -2185,6 +2191,7 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
soundsequences = parser.GetSoundSequences();
+ parser.Dispose();
}
//mxd. This loads cameratextures from ANIMDEFS
@@ -2252,6 +2259,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
+ parser.Dispose();
}
//mxd
diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs
index d5cbbc88..fc77db8b 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/PK3FileImage.cs b/Source/Core/Data/PK3FileImage.cs
index 3cc26d29..40dd54c4 100644
--- a/Source/Core/Data/PK3FileImage.cs
+++ b/Source/Core/Data/PK3FileImage.cs
@@ -130,7 +130,7 @@ namespace CodeImp.DoomBuilder.Data
{
bitmap = reader.ReadAsBitmap(filedata);
}
- catch (InvalidDataException)
+ catch(InvalidDataException)
{
// Data cannot be read!
bitmap = null;
diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs
index da9cdc12..a5134a8e 100644
--- a/Source/Core/Data/WADReader.cs
+++ b/Source/Core/Data/WADReader.cs
@@ -410,6 +410,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
+
+ parser.Dispose();
}
// This loads a set of textures
@@ -640,6 +642,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
+
+ parser.Dispose();
}
// This finds and returns a patch stream
@@ -702,6 +706,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
+
+ parser.Dispose();
}
// This finds and returns a sprite stream
diff --git a/Source/Core/Editing/EditMode.cs b/Source/Core/Editing/EditMode.cs
index 6e7a6255..37310d2b 100644
--- a/Source/Core/Editing/EditMode.cs
+++ b/Source/Core/Editing/EditMode.cs
@@ -78,9 +78,10 @@ namespace CodeImp.DoomBuilder.Editing
object[] attrs = this.GetType().GetCustomAttributes(true);
foreach(object a in attrs)
{
- if(a is EditModeAttribute)
+ EditModeAttribute attribute = a as EditModeAttribute;
+ if(attribute != null)
{
- attributes = (EditModeAttribute)a;
+ attributes = attribute;
break;
}
}
diff --git a/Source/Core/Editing/EditModeAttribute.cs b/Source/Core/Editing/EditModeAttribute.cs
index f80e226b..618f765b 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 501f013b..a6dace9b 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,6 +198,18 @@ namespace CodeImp.DoomBuilder.Editing
ClearUndos();
ClearRedos();
General.WriteLogLine("All undo and redo levels cleared.");
+
+ //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,6 +444,10 @@ namespace CodeImp.DoomBuilder.Editing
numcmds--;
}
}
+
+ //mxd
+ ds.End();
+ ds.Dispose();
General.Map.Map.AutoRemove = true;
}
diff --git a/Source/Core/Editing/UndoSnapshot.cs b/Source/Core/Editing/UndoSnapshot.cs
index 3ed421ed..af939e89 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/MultiSelectTreeview.cs b/Source/Core/GZBuilder/Controls/MultiSelectTreeview.cs
index 938b3d0d..35e8c71d 100644
--- a/Source/Core/GZBuilder/Controls/MultiSelectTreeview.cs
+++ b/Source/Core/GZBuilder/Controls/MultiSelectTreeview.cs
@@ -868,7 +868,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
{
if(tn.BackColor != SelectionBackColor)
{
- using (Pen p = new Pen(BackColor, 1))
+ using(Pen p = new Pen(BackColor, 1))
{
g.DrawRectangle(p, tnMostRecentSelectedNode.Bounds.X, tnMostRecentSelectedNode.Bounds.Y, tnMostRecentSelectedNode.Bounds.Width, tnMostRecentSelectedNode.Bounds.Height);
}
@@ -945,7 +945,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
base.OnMouseUp(e);
#if DEBUG
}
- catch (Exception ex)
+ catch(Exception ex)
{
// GKM - Untrapped exceptions were killing me for debugging purposes.
// It probably shouldn't be here permanently, but it was causing real trouble for me.
diff --git a/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs b/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
index 01228dd5..9da16f1c 100644
--- a/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
+++ b/Source/Core/GZBuilder/Controls/PairedFieldsControl.cs
@@ -95,12 +95,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
public void ApplyTo(UniFields fields, int min, int max, float oldValue1, float oldValue2)
{
- if(value1.Text != string.Empty)
+ 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)
+ 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 f090e396..061a2c38 100644
--- a/Source/Core/GZBuilder/Data/EngineInfo.cs
+++ b/Source/Core/GZBuilder/Data/EngineInfo.cs
@@ -4,8 +4,11 @@ using System.IO;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
- public class EngineInfo
+ public class EngineInfo : IDisposable
{
+ // Disposing
+ private bool isdisposed;
+
public const string DEFAULT_ENGINE_NAME = "Engine with no name";
private string testprogramname;
@@ -60,5 +63,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 779c0669..6448de5f 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 42433046..0fb06ef0 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;
+ if(lower != null) lower.Dispose();
lower = null;
}
diff --git a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
index 311bea14..251d1893 100644
--- a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
+++ b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs
@@ -22,9 +22,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
logPath = Path.Combine(General.SettingsPath, @"GZCrash.txt");
Exception ex = (Exception)e.ExceptionObject;
errorDescription.Text = "Error in " + ex.Source + ":";
+ 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;
diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs
index 37029917..0c75bb7b 100644
--- a/Source/Core/GZBuilder/md3/ModelReader.cs
+++ b/Source/Core/GZBuilder/md3/ModelReader.cs
@@ -767,7 +767,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3
//create texture
MemoryStream memstream = new MemoryStream((4096 * 4) + 4096);
- using (Bitmap bmp = CreateVoxelTexture(palette)) bmp.Save(memstream, ImageFormat.Bmp);
+ using(Bitmap bmp = CreateVoxelTexture(palette)) bmp.Save(memstream, ImageFormat.Bmp);
memstream.Seek(0, SeekOrigin.Begin);
Texture texture = Texture.FromStream(device, memstream, (int)memstream.Length, 64, 64, 0, Usage.None, Format.Unknown, Pool.Managed, Filter.Point, Filter.Box, 0);
diff --git a/Source/Core/General/Clock.cs b/Source/Core/General/Clock.cs
index a74eb5e3..4104c33f 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 57886301..52bb1fe8 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,8 +535,9 @@ 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());
+ 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;
@@ -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");
@@ -1408,7 +1384,7 @@ namespace CodeImp.DoomBuilder
editing.DisengageVolatileMode();
// Check if a wad file is known
- if(map.FilePathName == "")
+ if(string.IsNullOrEmpty(map.FilePathName))
{
// Call to SaveMapAs
result = SaveMapAs();
@@ -2106,13 +2082,13 @@ namespace CodeImp.DoomBuilder
EventLog.CreateEventSource("ThreadException", "Application");
// Create an EventLog instance and assign its source.
- using (EventLog myLog = new EventLog())
+ using(EventLog myLog = new EventLog())
{
myLog.Source = "ThreadException";
myLog.WriteEntry(exceptionmsg);
}
}
- catch (Exception exc)
+ catch(Exception exc)
{
MessageBox.Show("Could not write the error to the event log.\nReason: "
+ exc.Message + "\n\nInitial exception:\n" + exceptionmsg, "Fatal Non-UI Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
diff --git a/Source/Core/General/Launcher.cs b/Source/Core/General/Launcher.cs
index e787420c..305b8baa 100644
--- a/Source/Core/General/Launcher.cs
+++ b/Source/Core/General/Launcher.cs
@@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder
Cursor oldcursor = Cursor.Current;
// Check if configuration is OK
- if(General.Map.ConfigSettings.TestProgram == "" || !File.Exists(General.Map.ConfigSettings.TestProgram))
+ if(string.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram) || !File.Exists(General.Map.ConfigSettings.TestProgram))
{
//mxd. Let's be more precise
string message;
diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs
index 4a2449bc..4d79851c 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
@@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder
}
// Disposer
- internal bool Dispose()
+ public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@@ -234,11 +234,7 @@ namespace CodeImp.DoomBuilder
// Done
isdisposed = true;
- return true;
}
-
- // Already closed
- return true;
}
#endregion
@@ -828,7 +824,7 @@ namespace CodeImp.DoomBuilder
}
// Determine original map name
- string origmapname = (options.PreviousName != "" && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
+ string origmapname = (!string.IsNullOrEmpty(options.PreviousName) && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
string origwadfile = string.Empty; //mxd
try
@@ -1653,6 +1649,152 @@ namespace CodeImp.DoomBuilder
#endregion
+ #region ================== [mxd] GZDB actions
+
+ [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
@@ -1994,6 +2136,8 @@ 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 3e076faf..67db15e3 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 fce1e538..f1a29160 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 ee21947b..ec88bf22 100644
--- a/Source/Core/IO/Configuration.cs
+++ b/Source/Core/IO/Configuration.cs
@@ -445,7 +445,7 @@ namespace CodeImp.DoomBuilder.IO
bool validateresult;
// Check if key is an empty string
- if(key == "")
+ if(string.IsNullOrEmpty(key))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_KEYMISSING);
@@ -500,7 +500,7 @@ namespace CodeImp.DoomBuilder.IO
bool validateresult;
// Check if key is an empty string
- if(keyword == "")
+ if(string.IsNullOrEmpty(keyword))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_ASSIGNINVALID);
diff --git a/Source/Core/IO/DeserializerStream.cs b/Source/Core/IO/DeserializerStream.cs
index ade11dcf..1b7a2949 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,9 +34,10 @@ 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
@@ -57,6 +59,23 @@ namespace CodeImp.DoomBuilder.IO
this.reader = new BinaryReader(stream);
}
+ //mxd
+ public void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ if(reader != null) reader.Close();
+ if(stream != null)
+ {
+ stream.Dispose();
+ stream = null;
+ }
+
+ isdisposed = true;
+ }
+ }
+
#endregion
#region ================== Methods
diff --git a/Source/Core/IO/Lump.cs b/Source/Core/IO/Lump.cs
index 68186040..c187b997 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 805f9e44..c792334f 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,8 +34,9 @@ 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
@@ -56,6 +57,17 @@ namespace CodeImp.DoomBuilder.IO
this.stringstable = new Dictionary(StringComparer.Ordinal);
}
+ //mxd
+ public void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ if(writer != null) writer.Close();
+ isdisposed = true;
+ }
+ }
+
#endregion
#region ================== Methods
diff --git a/Source/Core/IO/UniversalMapSetIO.cs b/Source/Core/IO/UniversalMapSetIO.cs
index 533fd200..b4f38cca 100644
--- a/Source/Core/IO/UniversalMapSetIO.cs
+++ b/Source/Core/IO/UniversalMapSetIO.cs
@@ -52,7 +52,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 ab07dd1f..ba141c23 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 4a17c2b2..c1db896d 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 6830607f..362450df 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 79dc6a33..ea4eefc8 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 86bcacea..48c99361 100644
--- a/Source/Core/Map/MapOptions.cs
+++ b/Source/Core/Map/MapOptions.cs
@@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Map
// Change the name, but keep previous name
if(currentname != value)
{
- if(previousname == "") previousname = currentname;
+ if(string.IsNullOrEmpty(previousname)) previousname = currentname;
currentname = value;
}
}
diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs
index 516e7e9a..af167f07 100644
--- a/Source/Core/Map/MapSet.cs
+++ b/Source/Core/Map/MapSet.cs
@@ -899,6 +899,7 @@ namespace CodeImp.DoomBuilder.Map
ReadThings(deserializer);
deserializer.End();
+ deserializer.Dispose(); //mxd
// Make table of sidedef indices
sidedefindices = new Sidedef[numsidedefs];
diff --git a/Source/Core/Map/UniFields.cs b/Source/Core/Map/UniFields.cs
index b71f6ae6..db94b543 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 3b909ffe..1d98c929 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 6eb67d7c..9ea0201c 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 e328027c..1a040d94 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,7 +53,7 @@ namespace CodeImp.DoomBuilder.Rendering
private Capabilities devicecaps;
private Device device;
private Viewport viewport;
- private Dictionary resources;
+ private readonly HashSet resources;
private ShaderManager shaders;
private Surface backbuffer;
private Surface depthbuffer;
@@ -91,25 +91,29 @@ namespace CodeImp.DoomBuilder.Rendering
this.rendertarget = rendertarget;
// Create resources list
- resources = new Dictionary();
+ 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(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
@@ -324,7 +328,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal void RegisterResource(ID3DResource res)
{
// Add resource
- resources.Add(res, res);
+ resources.Add(res);
}
// This unregisters a resource
@@ -338,7 +342,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();
@@ -377,7 +381,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 dd301e03..b68aebe7 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 719b00e5..d72d14ea 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 208143db..3d76cd06 100644
--- a/Source/Core/Rendering/Renderer2D.cs
+++ b/Source/Core/Rendering/Renderer2D.cs
@@ -162,7 +162,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 9e416be4..91d0fd21 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 e9631fdc..d7a129b8 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 0cec5ca8..3e01d30c 100644
--- a/Source/Core/Rendering/World3DShader.cs
+++ b/Source/Core/Rendering/World3DShader.cs
@@ -39,15 +39,10 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
private readonly EffectHandle vertexColorHadle;
- //lights
- private readonly EffectHandle lightPositionAndRadiusHandle;
+ private readonly EffectHandle lightPositionAndRadiusHandle; //lights
private readonly EffectHandle lightColorHandle;
private readonly EffectHandle world;
- //fog
- private readonly EffectHandle camPosHandle;
- //used in ModelReader
- private readonly VertexElement[] vertexElements;
-
+ private readonly EffectHandle camPosHandle; //used for fog rendering
#endregion
@@ -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/Types/TypeHandlerAttribute.cs b/Source/Core/Types/TypeHandlerAttribute.cs
index a5679eb5..5f3afa76 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 50b6fc9e..e7a370d1 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 6fa86c64..77ae9efe 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/ChangeMapForm.cs b/Source/Core/Windows/ChangeMapForm.cs
index 702ac715..4be5ad3f 100644
--- a/Source/Core/Windows/ChangeMapForm.cs
+++ b/Source/Core/Windows/ChangeMapForm.cs
@@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Windows
{
mapsettings = new Configuration(dbsfile, true);
}
- catch (Exception)
+ catch(Exception)
{
mapsettings = new Configuration(true);
}
diff --git a/Source/Core/Windows/FlagsForm.cs b/Source/Core/Windows/FlagsForm.cs
index b1bba242..b2b871a2 100644
--- a/Source/Core/Windows/FlagsForm.cs
+++ b/Source/Core/Windows/FlagsForm.cs
@@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.Windows
flags.Add(tf.Value, tf.Key);
// Parse the value string and check the boxes if necessary
- if(value.Trim() != "")
+ if(!string.IsNullOrEmpty(value.Trim()))
{
foreach(string s in value.Split(','))
{
@@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.Windows
{
if(lf.Value == c.Text)
{
- if(value != "") value += ",";
+ if(!string.IsNullOrEmpty(value)) value += ",";
value += lf.Key;
}
}
diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs
index e0033320..85143e92 100644
--- a/Source/Core/Windows/MainForm.cs
+++ b/Source/Core/Windows/MainForm.cs
@@ -2472,7 +2472,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);
@@ -2534,7 +2534,7 @@ 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;
@@ -2561,7 +2561,7 @@ namespace CodeImp.DoomBuilder.Windows
for(int i = 0; i < recentitems.Length; i++)
{
// Recent file set?
- if(recentitems[i].Text != "")
+ if(!string.IsNullOrEmpty(recentitems[i].Text))
{
// Save to configuration
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
@@ -2603,7 +2603,7 @@ 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
@@ -3027,7 +3027,7 @@ namespace CodeImp.DoomBuilder.Windows
writer.Write(html.ToString());
}
}
- catch (Exception)
+ catch(Exception)
{
//Configurtions path SHOULD be accessible and not read-only, right?
path = Path.Combine(General.SettingsPath, fileName);
@@ -3884,24 +3884,15 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
- // Start annoying blinking!
- if(blink)
- {
- if(!blinkTimer.Enabled) blinkTimer.Start();
- }
- else
- {
- blinkTimer.Stop();
- warnsLabel.BackColor = SystemColors.Control;
- }
-
- // Update icon
+ // 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;
}
@@ -3925,6 +3916,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void blinkTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
+ if(!blinkTimer.Enabled) return;
try
{
this.Invoke(new CallBlink(Blink));
diff --git a/Source/Core/Windows/MapOptionsForm.cs b/Source/Core/Windows/MapOptionsForm.cs
index debc0164..dedceceb 100644
--- a/Source/Core/Windows/MapOptionsForm.cs
+++ b/Source/Core/Windows/MapOptionsForm.cs
@@ -185,7 +185,7 @@ 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);
diff --git a/Source/Core/Windows/TanColorTable.cs b/Source/Core/Windows/TanColorTable.cs
index 3ee9b87b..594cebff 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 997c96a8..9e0d04de 100644
--- a/Source/Core/ZDoom/DecorateParser.cs
+++ b/Source/Core/ZDoom/DecorateParser.cs
@@ -92,13 +92,19 @@ 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 7f6aad9d..715c7568 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,6 +55,9 @@ namespace CodeImp.DoomBuilder.ZDoom
private string errordesc;
private string errorsource;
private long prevstreamposition; //mxd. Text stream position storted before performing ReadToken.
+
+ //mxd. Disposing
+ protected bool isdisposed;
#endregion
@@ -77,6 +80,23 @@ namespace CodeImp.DoomBuilder.ZDoom
// Initialize
errordesc = null;
}
+
+ //mxd
+ public virtual void Dispose()
+ {
+ // Not already disposed?
+ if(!isdisposed)
+ {
+ if(datareader != null) datareader.Close();
+ if(datastream != null)
+ {
+ datastream.Dispose();
+ datastream = null;
+ }
+
+ isdisposed = true;
+ }
+ }
#endregion
@@ -588,7 +608,7 @@ 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/ErrorChecks/CheckMissingTextures.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs
index 2f638be8..b99e9b7a 100644
--- a/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs
+++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckMissingTextures.cs
@@ -86,7 +86,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Handle thread interruption
try { Thread.Sleep(0); }
- catch (ThreadInterruptedException) { return; }
+ catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)
diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckTextureAlignment.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckTextureAlignment.cs
index de554971..115bb8c5 100644
--- a/Source/Plugins/BuilderModes/ErrorChecks/CheckTextureAlignment.cs
+++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckTextureAlignment.cs
@@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
Thread.Sleep(0);
}
- catch (ThreadInterruptedException)
+ catch(ThreadInterruptedException)
{
// Clear collection
donesides.Clear();
diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckUnknownThings.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckUnknownThings.cs
index 038884e4..28b26e3e 100644
--- a/Source/Plugins/BuilderModes/ErrorChecks/CheckUnknownThings.cs
+++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckUnknownThings.cs
@@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Map.Data.GetThingInfoEx(t.Type) == null) SubmitResult(new ResultUnknownThing(t));
// Handle thread interruption
- try { Thread.Sleep(0); } catch (ThreadInterruptedException) { return; }
+ try { Thread.Sleep(0); } catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)
diff --git a/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs b/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs
index 0b52bd05..f9364b85 100644
--- a/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs
+++ b/Source/Plugins/BuilderModes/Interface/FitTexturesForm.cs
@@ -268,11 +268,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int x = side.Bounds.X - minx + margin;
int y = side.Bounds.Y - miny + margin;
- using (Pen p = new Pen(c))
+ using(Pen p = new Pen(c))
{
g.DrawRectangle(p, x, y, side.Bounds.Width, side.Bounds.Height);
}
- using (Brush b = new SolidBrush(c))
+ using(Brush b = new SolidBrush(c))
{
g.DrawString(i++ + ": line " + side.Side.Sidedef.Line.Index + "; x:" + side.Bounds.X + " y:" + side.Bounds.Y, this.Font, b, x + 2, y + 2);
}
diff --git a/Source/Plugins/ColorPicker/ColorWheel.cs b/Source/Plugins/ColorPicker/ColorWheel.cs
index fd15c512..16e2395f 100644
--- a/Source/Plugins/ColorPicker/ColorWheel.cs
+++ b/Source/Plugins/ColorPicker/ColorWheel.cs
@@ -81,7 +81,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// (colorRectangle), brightness "strip" (brightnessRectangle)
// and location to display selected color (selectedColorRectangle).
- using (GraphicsPath path = new GraphicsPath())
+ using(GraphicsPath path = new GraphicsPath())
{
// Store away locations for later use.
this.colorRectangle = colorRectangle;
@@ -358,7 +358,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// Given the top color, draw a linear gradient
// ranging from black to the top color. Use the
// brightness rectangle as the area to fill.
- using (LinearGradientBrush lgb = new LinearGradientBrush(brightnessRectangle, TopColor,
+ using(LinearGradientBrush lgb = new LinearGradientBrush(brightnessRectangle, TopColor,
Color.Black, LinearGradientMode.Vertical))
{
g.FillRectangle(lgb, brightnessRectangle);
@@ -399,7 +399,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
{
// Create a new PathGradientBrush, supplying an array of points created by calling
// the GetPoints method.
- using (PathGradientBrush pgb = new PathGradientBrush(GetPoints(radius, new Point(radius, radius))))
+ using(PathGradientBrush pgb = new PathGradientBrush(GetPoints(radius, new Point(radius, radius))))
{
// Set the various properties. Note the SurroundColors property, which contains an array of points,
// in a one-to-one relationship with the points that created the gradient.
@@ -412,7 +412,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// rather than recreating the gradient.
colorImage = new Bitmap(colorRectangle.Width, colorRectangle.Height, PixelFormat.Format32bppArgb);
- using (Graphics newGraphics = Graphics.FromImage(colorImage))
+ using(Graphics newGraphics = Graphics.FromImage(colorImage))
{
newGraphics.FillEllipse(pgb, 0, 0, colorRectangle.Width, colorRectangle.Height);
}
diff --git a/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs b/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
index 35677319..3ad040b9 100644
--- a/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
+++ b/Source/Plugins/StairSectorBuilder/StairSectorBuilderMode.cs
@@ -1358,7 +1358,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
General.Map.Map.Update();
General.Map.IsChanged = true;
}
- catch (Exception e)
+ catch(Exception e)
{
General.Interface.DisplayStatus(StatusType.Warning, e.ToString());
General.Map.UndoRedo.WithdrawUndo();
diff --git a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs
index decde417..0da111e5 100644
--- a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs
+++ b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs
@@ -988,7 +988,7 @@ namespace CodeImp.DoomBuilder.TagExplorer
using(StreamWriter sw = File.CreateText(saveFileDialog.FileName)) sw.Write(sb.ToString());
General.Interface.DisplayStatus(StatusType.Info, "Tag info successfully saved.");
}
- catch (Exception ex)
+ catch(Exception ex)
{
General.ErrorLogger.Add(ErrorType.Error, "Failed to save tag info: " + ex.Message);
General.Interface.DisplayStatus(StatusType.Info, "Failed to save tag info...");