diff --git a/OpenDiablo2.Common/Models/BitMuncher.cs b/OpenDiablo2.Common/Models/BitMuncher.cs
index 8702759e..3b8586ab 100644
--- a/OpenDiablo2.Common/Models/BitMuncher.cs
+++ b/OpenDiablo2.Common/Models/BitMuncher.cs
@@ -42,7 +42,7 @@ namespace OpenDiablo2.Common.Models
var result = 0U;
for (var i = 0; i < bits; i++)
- result |= (GetBit() << i);
+ result |= GetBit() << i;
return result;
}
diff --git a/OpenDiablo2.Common/Models/LevelDetail.cs b/OpenDiablo2.Common/Models/LevelDetail.cs
index 3d071341..28d9dbbd 100644
--- a/OpenDiablo2.Common/Models/LevelDetail.cs
+++ b/OpenDiablo2.Common/Models/LevelDetail.cs
@@ -264,7 +264,7 @@ namespace OpenDiablo2.Common.Models
for (int j = 0; j < 5; j++) result.ObjGrp0_7[j] = Convert.ToInt32(v[i++]);
result.ObjPrb0_7 = new int[8];
for (int j = 0; j < 5; j++) result.ObjPrb0_7[j] = Convert.ToInt32(v[i++]);
- result.Beta = Convert.ToInt32(v[i++]) == 1;
+ result.Beta = Convert.ToInt32(v[i]) == 1;
return result;
diff --git a/OpenDiablo2.Common/Models/MPQ.cs b/OpenDiablo2.Common/Models/MPQ.cs
index 467223be..531731db 100644
--- a/OpenDiablo2.Common/Models/MPQ.cs
+++ b/OpenDiablo2.Common/Models/MPQ.cs
@@ -1,4 +1,20 @@
-using System;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -11,14 +27,10 @@ namespace OpenDiablo2.Common.Models
public sealed class MPQ : IDisposable
{
private const string HEADER_SIGNATURE = "MPQ\x1A";
- //private const string USERDATA_SIGNATURE = "MPQ\x1B";
private const string LISTFILE_NAME = "(listfile)";
private const int MPQ_HASH_FILE_KEY = 3;
- private const int MPQ_HASH_TABLE_OFFSET = 0;
private const int MPQ_HASH_NAME_A = 1;
private const int MPQ_HASH_NAME_B = 2;
- private const UInt32 MPQ_HASH_ENTRY_EMPTY = 0xFFFFFFFF;
- private const UInt32 MPQ_HASH_ENTRY_DELETED = 0xFFFFFFFE;
internal struct HeaderRecord
{
@@ -34,9 +46,7 @@ namespace OpenDiablo2.Common.Models
}
[Flags]
-#pragma warning disable IDE1006 // Naming Styles
- internal enum eBlockRecordFlags : UInt32
-#pragma warning restore IDE1006 // Naming Styles
+ internal enum eBlockRecordBitflag : UInt32
{
IsFile = 0x80000000, // Block is a file, and follows the file data format; otherwise, block is free space or unused. If the block is not a file, all other flags should be cleared, and FileSize should be 0.
SingleUnit = 0x01000000, // File is stored as a single unit, rather than split into sectors.
@@ -55,12 +65,12 @@ namespace OpenDiablo2.Common.Models
public uint EncryptionSeed { get; set; }
public string FileName { get; internal set; }
- public bool IsFile => (Flags & (UInt32)eBlockRecordFlags.IsFile) != 0;
- public bool SingleUnit => (Flags & (UInt32)eBlockRecordFlags.SingleUnit) != 0;
- public bool KeyAdjusted => (Flags & (UInt32)eBlockRecordFlags.KeyAdjusted) != 0;
- public bool IsEncrypted => (Flags & (UInt32)eBlockRecordFlags.IsEncrypted) != 0;
- public bool IsCompressed => (Flags & (UInt32)eBlockRecordFlags.IsCompressed) != 0;
- public bool IsImploded => (Flags & (UInt32)eBlockRecordFlags.IsImploded) != 0;
+ public bool IsFile => (Flags & (UInt32)eBlockRecordBitflag.IsFile) != 0;
+ public bool SingleUnit => (Flags & (UInt32)eBlockRecordBitflag.SingleUnit) != 0;
+ public bool KeyAdjusted => (Flags & (UInt32)eBlockRecordBitflag.KeyAdjusted) != 0;
+ public bool IsEncrypted => (Flags & (UInt32)eBlockRecordBitflag.IsEncrypted) != 0;
+ public bool IsCompressed => (Flags & (UInt32)eBlockRecordBitflag.IsCompressed) != 0;
+ public bool IsImploded => (Flags & (UInt32)eBlockRecordBitflag.IsImploded) != 0;
}
internal struct HashRecord
@@ -72,13 +82,13 @@ namespace OpenDiablo2.Common.Models
public UInt32 FileBlockIndex;
}
- internal static UInt32[] cryptTable = new UInt32[0x500];
+ internal static readonly UInt32[] cryptTable = new UInt32[0x500];
internal HeaderRecord Header;
private readonly List blockTable = new List();
private readonly List hashTable = new List();
internal Stream fileStream;
- public UInt16 LanguageId = 0;
+ public UInt16 LanguageId { get; internal set; } = 0;
public const byte Platform = 0;
public string Path { get; private set; }
@@ -139,7 +149,7 @@ namespace OpenDiablo2.Common.Models
seed = (seed * 125 + 3) % 0x2AAAAB;
- cryptTable[index2] = (temp | (seed & 0xFFFF));
+ cryptTable[index2] = temp | (seed & 0xFFFF);
}
}
}
@@ -171,15 +181,15 @@ namespace OpenDiablo2.Common.Models
seed2 += cryptTable[(int)(0x400 + (seed1 & 0xff))];
uint result = BitConverter.ToUInt32(data, i);
- result ^= (seed1 + seed2);
+ result ^= seed1 + seed2;
seed1 = ((~seed1 << 21) + 0x11111111) | (seed1 >> 11);
seed2 = result + seed2 + (seed2 << 5) + 3;
- data[i + 0] = ((byte)(result & 0xff));
- data[i + 1] = ((byte)((result >> 8) & 0xff));
- data[i + 2] = ((byte)((result >> 16) & 0xff));
- data[i + 3] = ((byte)((result >> 24) & 0xff));
+ data[i + 0] = (byte)(result & 0xff);
+ data[i + 1] = (byte)((result >> 8) & 0xff);
+ data[i + 2] = (byte)((result >> 16) & 0xff);
+ data[i + 3] = (byte)((result >> 24) & 0xff);
}
}
@@ -269,6 +279,7 @@ namespace OpenDiablo2.Common.Models
return seed1;
}
+ /*
private static UInt32 ComputeFileKey(string filePath, BlockRecord blockRecord, UInt32 archiveOffset)
{
var fileName = filePath.Split('\\').Last();
@@ -282,13 +293,13 @@ namespace OpenDiablo2.Common.Models
return fileKey;
}
-
+
private bool FindFileInHashTable(string filePath, out UInt32 fileHashEntry)
{
fileHashEntry = 0;
// Find the home entry in the hash table for the file
- UInt32 initEntry = HashString(filePath, MPQ_HASH_TABLE_OFFSET) & (UInt32)(Header.HashTableSize - 1);
+ UInt32 initEntry = HashString(filePath, MPQ_HASH_TABLE_OFFSET) & Header.HashTableSize - 1;
// Is there anything there at all?
if (hashTable[(int)initEntry].FileBlockIndex == MPQ_HASH_ENTRY_EMPTY)
@@ -315,12 +326,12 @@ namespace OpenDiablo2.Common.Models
}
}
- iCurEntry = (iCurEntry + 1) & (UInt32)(Header.HashTableSize - 1);
+ iCurEntry = (iCurEntry + 1) & Header.HashTableSize - 1;
} while (iCurEntry != initEntry && hashTable[(int)iCurEntry].FileBlockIndex != MPQ_HASH_ENTRY_EMPTY);
return false;
}
-
+ */
private bool GetHashRecord(string fileName, out HashRecord hash)
{
uint index = HashString(fileName, 0);
@@ -328,7 +339,7 @@ namespace OpenDiablo2.Common.Models
uint name1 = HashString(fileName, MPQ_HASH_NAME_A);
uint name2 = HashString(fileName, MPQ_HASH_NAME_B);
- for (uint i = index; i < hashTable.Count(); ++i)
+ for (uint i = index; i < hashTable.Count; ++i)
{
hash = hashTable[(int)i];
if (hash.FilePathHashA == name1 && hash.FilePathHashB == name2)
diff --git a/OpenDiablo2.Common/Models/MPQCOF.cs b/OpenDiablo2.Common/Models/MPQCOF.cs
index 6590465e..71a61000 100644
--- a/OpenDiablo2.Common/Models/MPQCOF.cs
+++ b/OpenDiablo2.Common/Models/MPQCOF.cs
@@ -48,7 +48,7 @@ namespace OpenDiablo2.Common.Models
var numLayers = br.ReadByte();
var framesPerDir = br.ReadByte();
- var numDirections = br.ReadByte();
+ br.ReadByte(); // Number of directions
br.ReadBytes(25); // Skip 25 unknown bytes...
diff --git a/OpenDiablo2.Common/Models/MPQDCC.cs b/OpenDiablo2.Common/Models/MPQDCC.cs
index ae42efc6..70c100f2 100644
--- a/OpenDiablo2.Common/Models/MPQDCC.cs
+++ b/OpenDiablo2.Common/Models/MPQDCC.cs
@@ -11,24 +11,24 @@ namespace OpenDiablo2.Common.Models
{
public sealed class PixelBufferEntry
{
- public byte[] Value;
- public int Frame;
- public int FrameCellIndex;
+ public byte[] Value { get; internal set; }
+ public int Frame { get; internal set; }
+ public int FrameCellIndex { get; internal set; }
}
public sealed class Cell
{
- public int Width;
- public int Height;
- public int XOffset;
- public int YOffset;
+ public int Width { get; internal set; }
+ public int Height { get; internal set; }
+ public int XOffset { get; internal set; }
+ public int YOffset { get; internal set; }
- public int LastWidth;
- public int LastHeight;
- public int LastXOffset;
- public int LastYOffset;
+ public int LastWidth { get; internal set; }
+ public int LastHeight { get; internal set; }
+ public int LastXOffset { get; internal set; }
+ public int LastYOffset { get; internal set; }
- public byte[] PixelData;
+ public byte[] PixelData { get; internal set; }
}
public sealed class MPQDCCDirectionFrame
@@ -49,7 +49,7 @@ namespace OpenDiablo2.Common.Models
public MPQDCCDirectionFrame(BitMuncher bits, MPQDCCDirection direction)
{
- var variable0 = bits.GetBits(direction.Variable0Bits);
+ bits.GetBits(direction.Variable0Bits); // Variable0
Width = (int)bits.GetBits(direction.WidthBits);
Height = (int)bits.GetBits(direction.HeightBits);
XOffset = bits.GetSignedBits(direction.XOffsetBits);
@@ -218,7 +218,7 @@ namespace OpenDiablo2.Common.Models
for (var i = 0; i < 256; i++)
paletteEntries.Add(bm.GetBit() != 0);
- PaletteEntries = new byte[paletteEntries.Count(x => x == true)];
+ PaletteEntries = new byte[paletteEntries.Count(x => x)];
var paletteOffset = 0;
for (var i = 0; i < 256; i++)
{
@@ -295,8 +295,6 @@ namespace OpenDiablo2.Common.Models
foreach (var frame in Frames)
{
frameIndex++;
- var numberOfCells = frame.HorizontalCellCount * frame.VerticalCellCount;
-
var c = -1;
foreach (var cell in frame.Cells)
{
@@ -393,7 +391,7 @@ namespace OpenDiablo2.Common.Models
var currentCellY = cellY + originCellY;
for (var cellX = 0; cellX < frame.HorizontalCellCount; cellX++, frameCellIndex++)
{
- var currentCell = (originCellX + cellX) + (currentCellY * HorizontalCellCount);
+ var currentCell = originCellX + cellX + (currentCellY * HorizontalCellCount);
var nextCell = false;
var tmp = 0;
if (cellBuffer[currentCell] != null)
diff --git a/OpenDiablo2.Common/Models/MPQDS1.cs b/OpenDiablo2.Common/Models/MPQDS1.cs
index e5dc099d..64050e8e 100644
--- a/OpenDiablo2.Common/Models/MPQDS1.cs
+++ b/OpenDiablo2.Common/Models/MPQDS1.cs
@@ -60,12 +60,12 @@ namespace OpenDiablo2.Common.Models
public struct DS1LookupTable
{
- public int Orientation;
- public int MainIndex;
- public int SubIndex;
- public int Frame;
+ public int Orientation { get; internal set; }
+ public int MainIndex { get; internal set; }
+ public int SubIndex { get; internal set; }
+ public int Frame { get; internal set; }
- public MPQDT1Tile TileRef;
+ public MPQDT1Tile TileRef { get; internal set; }
}
diff --git a/OpenDiablo2.Common/Models/MPQStream.cs b/OpenDiablo2.Common/Models/MPQStream.cs
index d3ea7553..7594546e 100644
--- a/OpenDiablo2.Common/Models/MPQStream.cs
+++ b/OpenDiablo2.Common/Models/MPQStream.cs
@@ -328,13 +328,13 @@ namespace OpenDiablo2.Common.Models
target = Length + offset;
break;
default:
- throw new ArgumentException("Origin", "Invalid SeekOrigin");
+ throw new ArgumentException("Invalid SeekOrigin", "origin");
}
if (target < 0)
- throw new ArgumentOutOfRangeException("Attmpted to Seek before the beginning of the stream");
+ throw new ArgumentOutOfRangeException("offset", "Attmpted to Seek before the beginning of the stream");
if (target >= Length)
- throw new ArgumentOutOfRangeException("Attmpted to Seek beyond the end of the stream");
+ throw new ArgumentOutOfRangeException("offset", "Attmpted to Seek beyond the end of the stream");
position = target;
diff --git a/OpenDiablo2.Common/Models/MPQWavCompression.cs b/OpenDiablo2.Common/Models/MPQWavCompression.cs
index 923b56a4..86ecd9db 100644
--- a/OpenDiablo2.Common/Models/MPQWavCompression.cs
+++ b/OpenDiablo2.Common/Models/MPQWavCompression.cs
@@ -85,17 +85,17 @@ namespace OpenDiablo2.Common.Models
int temp2 = temp1 >> shift;
if ((value & 1) != 0)
- temp2 += (temp1 >> 0);
+ temp2 += temp1 >> 0;
if ((value & 2) != 0)
- temp2 += (temp1 >> 1);
+ temp2 += temp1 >> 1;
if ((value & 4) != 0)
- temp2 += (temp1 >> 2);
+ temp2 += temp1 >> 2;
if ((value & 8) != 0)
- temp2 += (temp1 >> 3);
+ temp2 += temp1 >> 3;
if ((value & 0x10) != 0)
- temp2 += (temp1 >> 4);
+ temp2 += temp1 >> 4;
if ((value & 0x20) != 0)
- temp2 += (temp1 >> 5);
+ temp2 += temp1 >> 5;
int temp3 = Array2[channel];
if ((value & 0x40) != 0)
diff --git a/OpenDiablo2.Common/Models/Mobs/LevelExperienceConfig.cs b/OpenDiablo2.Common/Models/Mobs/LevelExperienceConfig.cs
index 2ba2ef55..3eb6dd2d 100644
--- a/OpenDiablo2.Common/Models/Mobs/LevelExperienceConfig.cs
+++ b/OpenDiablo2.Common/Models/Mobs/LevelExperienceConfig.cs
@@ -11,7 +11,7 @@ namespace OpenDiablo2.Common.Models.Mobs
{
public class LevelExperienceConfig : ILevelExperienceConfig
{
- private readonly List ExperiencePerLevel = new List();
+ private readonly List ExperiencePerLevel;
public LevelExperienceConfig(List expperlevel)
{
diff --git a/OpenDiablo2.Common/Models/Mobs/MobState.cs b/OpenDiablo2.Common/Models/Mobs/MobState.cs
index 19541819..cea83a1b 100644
--- a/OpenDiablo2.Common/Models/Mobs/MobState.cs
+++ b/OpenDiablo2.Common/Models/Mobs/MobState.cs
@@ -174,5 +174,6 @@ namespace OpenDiablo2.Common.Models.Mobs
public static bool operator >(MobState obj1, MobState obj2) => obj1?.Id > obj2?.Id;
public static bool operator <=(MobState obj1, MobState obj2) => obj1?.Id <= obj2?.Id;
public static bool operator >=(MobState obj1, MobState obj2) => obj1?.Id >= obj2?.Id;
+ public override int GetHashCode() => Id.GetHashCode();
}
}
diff --git a/OpenDiablo2.Common/Models/Mobs/PlayerState.cs b/OpenDiablo2.Common/Models/Mobs/PlayerState.cs
index 5c5203b5..2a844200 100644
--- a/OpenDiablo2.Common/Models/Mobs/PlayerState.cs
+++ b/OpenDiablo2.Common/Models/Mobs/PlayerState.cs
@@ -1,4 +1,20 @@
-using System;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using System;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Enums.Mobs;
using OpenDiablo2.Common.Interfaces.Mobs;
@@ -124,7 +140,7 @@ namespace OpenDiablo2.Common.Models.Mobs
{
// on even levels, e.g. 2, 4, 6, you gain 1 from an increase of 1.5
// on odd levels, you gain 2 from an increase of 1.5
- return (int)(((Level % 2) * Math.Ceiling(increase)) + ((1 - (Level % 2)) * Math.Floor(increase)));
+ return (int)((Level % 2 * Math.Ceiling(increase)) + ((1 - (Level % 2)) * Math.Floor(increase)));
}
#endregion Level and Experience
diff --git a/OpenDiablo2.Common/Models/Mobs/Stat.cs b/OpenDiablo2.Common/Models/Mobs/Stat.cs
index 6e2fdf56..b7be2a40 100644
--- a/OpenDiablo2.Common/Models/Mobs/Stat.cs
+++ b/OpenDiablo2.Common/Models/Mobs/Stat.cs
@@ -1,10 +1,21 @@
-using OpenDiablo2.Common.Enums.Mobs;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using OpenDiablo2.Common.Enums.Mobs;
using OpenDiablo2.Common.Interfaces.Mobs;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace OpenDiablo2.Common.Models.Mobs
{
@@ -14,7 +25,7 @@ namespace OpenDiablo2.Common.Models.Mobs
protected int Max = 0;
protected int Current = 0; // the current value BEFORE modifiers
- public bool AllowedToOverflowFromModifiers = false; // if true, can return a value greater than Max
+ public bool AllowedToOverflowFromModifiers { get; set; } = false; // if true, can return a value greater than Max
// if a modifier is increasing the current value
public Stat(int min, int max, int current, bool allowedToOverflowFromModifiers)
diff --git a/OpenDiablo2.Common/Models/Mobs/StatDouble.cs b/OpenDiablo2.Common/Models/Mobs/StatDouble.cs
index bc5eedaa..40c666cc 100644
--- a/OpenDiablo2.Common/Models/Mobs/StatDouble.cs
+++ b/OpenDiablo2.Common/Models/Mobs/StatDouble.cs
@@ -14,7 +14,7 @@ namespace OpenDiablo2.Common.Models.Mobs
protected double Max = 0;
protected double Current = 0; // the current value BEFORE modifiers
- public bool AllowedToOverflowFromModifiers = false; // if true, can return a value greater than Max
+ public bool AllowedToOverflowFromModifiers { get; set; } = false; // if true, can return a value greater than Max
// if a modifier is increasing the current value
public StatDouble(double min, double max, double current, bool allowedToOverflowFromModifiers)
diff --git a/OpenDiablo2.Common/Models/Mobs/StatModifier.cs b/OpenDiablo2.Common/Models/Mobs/StatModifier.cs
index 29bfeb45..1e53e1cb 100644
--- a/OpenDiablo2.Common/Models/Mobs/StatModifier.cs
+++ b/OpenDiablo2.Common/Models/Mobs/StatModifier.cs
@@ -1,16 +1,27 @@
-using OpenDiablo2.Common.Enums.Mobs;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using OpenDiablo2.Common.Enums.Mobs;
using OpenDiablo2.Common.Interfaces.Mobs;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace OpenDiablo2.Common.Models.Mobs
{
public class StatModifierAddition : IStatModifier
{
- public double Value = 0;
+ public double Value { get; set; } = 0;
public int Priority { get; private set; }
public string Name { get; private set; }
public eStatModifierType ModifierType { get; private set; }
@@ -33,7 +44,7 @@ namespace OpenDiablo2.Common.Models.Mobs
public class StatModifierMultiplication : IStatModifier
{
- public double Value = 0;
+ public double Value { get; set; } = 0;
public int Priority { get; private set; }
public string Name { get; private set; }
public eStatModifierType ModifierType { get; private set; }
@@ -62,11 +73,11 @@ namespace OpenDiablo2.Common.Models.Mobs
switch (ModifierType)
{
case eStatModifierType.CURRENT:
- return (current * Value);
+ return current * Value;
case eStatModifierType.MAX:
- return (max * Value);
+ return max * Value;
case eStatModifierType.MIN:
- return (min * Value);
+ return min * Value;
}
return 0; // shouldn't reach this
}
diff --git a/OpenDiablo2.Common/Models/PKLibDecompress.cs b/OpenDiablo2.Common/Models/PKLibDecompress.cs
index 34b58715..55410b86 100644
--- a/OpenDiablo2.Common/Models/PKLibDecompress.cs
+++ b/OpenDiablo2.Common/Models/PKLibDecompress.cs
@@ -187,7 +187,7 @@ namespace OpenDiablo2.Common.Models
private int DecodeDist(int length)
{
- if (_bitstream.EnsureBits(8) == false) return 0;
+ if (!_bitstream.EnsureBits(8)) return 0;
int pos = sPosition1[_bitstream.PeekByte()];
byte skip = sDistBits[pos]; // Number of bits to skip
@@ -196,13 +196,13 @@ namespace OpenDiablo2.Common.Models
if (length == 2)
{
- if (_bitstream.EnsureBits(2) == false) return 0;
+ if (!_bitstream.EnsureBits(2)) return 0;
pos = (pos << 2) | _bitstream.ReadBits(2);
}
else
{
- if (_bitstream.EnsureBits(_dictSizeBits) == false) return 0;
- pos = ((pos << _dictSizeBits)) | _bitstream.ReadBits(_dictSizeBits);
+ if (!_bitstream.EnsureBits(_dictSizeBits)) return 0;
+ pos = (pos << _dictSizeBits) | _bitstream.ReadBits(_dictSizeBits);
}
return pos + 1;
diff --git a/OpenDiablo2.Common/Models/Palette.cs b/OpenDiablo2.Common/Models/Palette.cs
index cffc01e8..c690e441 100644
--- a/OpenDiablo2.Common/Models/Palette.cs
+++ b/OpenDiablo2.Common/Models/Palette.cs
@@ -26,7 +26,7 @@ namespace OpenDiablo2.Common.Models
var b = br.ReadByte();
var g = br.ReadByte();
var r = br.ReadByte();
- result.Colors[i] = ((UInt32)255 << 24) + ((UInt32)r << 16) + ((UInt32)g << 8) + (UInt32)b;
+ result.Colors[i] = ((UInt32)255 << 24) + ((UInt32)r << 16) + ((UInt32)g << 8) + b;
}
return result;
diff --git a/OpenDiablo2.Common/Models/PlayerInfo.cs b/OpenDiablo2.Common/Models/PlayerInfo.cs
index 963ab8ee..d04f66cb 100644
--- a/OpenDiablo2.Common/Models/PlayerInfo.cs
+++ b/OpenDiablo2.Common/Models/PlayerInfo.cs
@@ -1,4 +1,20 @@
-using System;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using System;
using System.Collections.Generic;
using System.Text;
using OpenDiablo2.Common.Enums;
@@ -24,7 +40,7 @@ namespace OpenDiablo2.Common.Models
result.Add((byte)WeaponClass);
result.Add((byte)ArmorType);
result.Add((byte)MobMode);
- result.AddRange(BitConverter.GetBytes((Int32)nameBytes.Length));
+ result.AddRange(BitConverter.GetBytes(nameBytes.Length));
result.AddRange(nameBytes);
result.AddRange(LocationDetails.GetBytes());
result.AddRange(UID.ToByteArray());
diff --git a/OpenDiablo2.Common/Models/PlayerLocationDetails.cs b/OpenDiablo2.Common/Models/PlayerLocationDetails.cs
index 8dce61d6..03a7412d 100644
--- a/OpenDiablo2.Common/Models/PlayerLocationDetails.cs
+++ b/OpenDiablo2.Common/Models/PlayerLocationDetails.cs
@@ -1,4 +1,20 @@
-using System;
+/* OpenDiablo 2 - An open source re-implementation of Diablo 2 in C#
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+using System;
using System.Collections.Generic;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Models.Mobs;
@@ -18,12 +34,12 @@ namespace OpenDiablo2.Common.Models
public byte[] GetBytes()
{
var result = new List();
- result.AddRange(BitConverter.GetBytes((Int32)PlayerId));
- result.AddRange(BitConverter.GetBytes((float)PlayerX));
- result.AddRange(BitConverter.GetBytes((float)PlayerY));
- result.AddRange(BitConverter.GetBytes((Int32)MovementDirection));
+ result.AddRange(BitConverter.GetBytes(PlayerId));
+ result.AddRange(BitConverter.GetBytes(PlayerX));
+ result.AddRange(BitConverter.GetBytes(PlayerY));
+ result.AddRange(BitConverter.GetBytes(MovementDirection));
result.AddRange(BitConverter.GetBytes((byte)MovementType));
- result.AddRange(BitConverter.GetBytes((float)MovementSpeed));
+ result.AddRange(BitConverter.GetBytes(MovementSpeed));
return result.ToArray();
}
@@ -54,7 +70,7 @@ namespace OpenDiablo2.Common.Models
PlayerY = source.GetPosition().Y,
MovementType = source.MovementType,
MovementDirection = source.MovementDirection,
- MovementSpeed = (float)(source.MovementType == eMovementType.Running ? source.GetRunVelocity() : source.GetWalkVeloicty()) / 4f
+ MovementSpeed = (source.MovementType == eMovementType.Running ? source.GetRunVelocity() : source.GetWalkVeloicty()) / 4f
};
return result;
}
diff --git a/OpenDiablo2.Common/ResourcePaths.cs b/OpenDiablo2.Common/ResourcePaths.cs
index 5a5cd8a7..f430a8b6 100644
--- a/OpenDiablo2.Common/ResourcePaths.cs
+++ b/OpenDiablo2.Common/ResourcePaths.cs
@@ -9,142 +9,142 @@ namespace OpenDiablo2.Common
public static class ResourcePaths
{
// --- Loading Screen ---
- public static string LoadingScreen = "data\\global\\ui\\Loading\\loadingscreen.dc6";
+ public static string LoadingScreen { get; } = "data\\global\\ui\\Loading\\loadingscreen.dc6";
// --- Main Menu ---
- public static string GameSelectScreen = "data\\global\\ui\\FrontEnd\\gameselectscreenEXP.dc6";
- public static string Diablo2LogoFireLeft = "data\\global\\ui\\FrontEnd\\D2logoFireLeft.DC6";
- public static string Diablo2LogoFireRight = "data\\global\\ui\\FrontEnd\\D2logoFireRight.DC6";
- public static string Diablo2LogoBlackLeft = "data\\global\\ui\\FrontEnd\\D2logoBlackLeft.DC6";
- public static string Diablo2LogoBlackRight = "data\\global\\ui\\FrontEnd\\D2logoBlackRight.DC6";
+ public static string GameSelectScreen { get; } = "data\\global\\ui\\FrontEnd\\gameselectscreenEXP.dc6";
+ public static string Diablo2LogoFireLeft { get; } = "data\\global\\ui\\FrontEnd\\D2logoFireLeft.DC6";
+ public static string Diablo2LogoFireRight { get; } = "data\\global\\ui\\FrontEnd\\D2logoFireRight.DC6";
+ public static string Diablo2LogoBlackLeft { get; } = "data\\global\\ui\\FrontEnd\\D2logoBlackLeft.DC6";
+ public static string Diablo2LogoBlackRight { get; } = "data\\global\\ui\\FrontEnd\\D2logoBlackRight.DC6";
// --- Character Select Screen ---
- public static string CharacterSelectBackground = "data\\global\\ui\\FrontEnd\\charactercreationscreenEXP.dc6";
- public static string CharacterSelectCampfire = "data\\global\\ui\\FrontEnd\\fire.DC6";
+ public static string CharacterSelectBackground { get; } = "data\\global\\ui\\FrontEnd\\charactercreationscreenEXP.dc6";
+ public static string CharacterSelectCampfire { get; } = "data\\global\\ui\\FrontEnd\\fire.DC6";
- public static string CharacterSelectBarbarianUnselected = "data\\global\\ui\\FrontEnd\\barbarian\\banu1.DC6";
- public static string CharacterSelectBarbarianUnselectedH = "data\\global\\ui\\FrontEnd\\barbarian\\banu2.DC6";
- public static string CharacterSelectBarbarianSelected = "data\\global\\ui\\FrontEnd\\barbarian\\banu3.DC6";
- public static string CharacterSelectBarbarianForwardWalk = "data\\global\\ui\\FrontEnd\\barbarian\\bafw.DC6";
- public static string CharacterSelectBarbarianForwardWalkOverlay = "data\\global\\ui\\FrontEnd\\barbarian\\BAFWs.DC6";
- public static string CharacterSelectBarbarianBackWalk = "data\\global\\ui\\FrontEnd\\barbarian\\babw.DC6";
+ public static string CharacterSelectBarbarianUnselected { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\banu1.DC6";
+ public static string CharacterSelectBarbarianUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\banu2.DC6";
+ public static string CharacterSelectBarbarianSelected { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\banu3.DC6";
+ public static string CharacterSelectBarbarianForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\bafw.DC6";
+ public static string CharacterSelectBarbarianForwardWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\BAFWs.DC6";
+ public static string CharacterSelectBarbarianBackWalk { get; } = "data\\global\\ui\\FrontEnd\\barbarian\\babw.DC6";
- public static string CharacterSelecSorceressUnselected = "data\\global\\ui\\FrontEnd\\sorceress\\SONU1.DC6";
- public static string CharacterSelecSorceressUnselectedH = "data\\global\\ui\\FrontEnd\\sorceress\\SONU2.DC6";
- public static string CharacterSelecSorceressSelected = "data\\global\\ui\\FrontEnd\\sorceress\\SONU3.DC6";
- public static string CharacterSelecSorceressSelectedOverlay = "data\\global\\ui\\FrontEnd\\sorceress\\SONU3s.DC6";
- public static string CharacterSelecSorceressForwardWalk= "data\\global\\ui\\FrontEnd\\sorceress\\SOFW.DC6";
- public static string CharacterSelecSorceressForwardWalkOverlay = "data\\global\\ui\\FrontEnd\\sorceress\\SOFWs.DC6";
- public static string CharacterSelecSorceressBackWalk = "data\\global\\ui\\FrontEnd\\sorceress\\SOBW.DC6";
- public static string CharacterSelecSorceressBackWalkOverlay = "data\\global\\ui\\FrontEnd\\sorceress\\SOBWs.DC6";
+ public static string CharacterSelecSorceressUnselected { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SONU1.DC6";
+ public static string CharacterSelecSorceressUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SONU2.DC6";
+ public static string CharacterSelecSorceressSelected { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SONU3.DC6";
+ public static string CharacterSelecSorceressSelectedOverlay { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SONU3s.DC6";
+ public static string CharacterSelecSorceressForwardWalk{ get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SOFW.DC6";
+ public static string CharacterSelecSorceressForwardWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SOFWs.DC6";
+ public static string CharacterSelecSorceressBackWalk { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SOBW.DC6";
+ public static string CharacterSelecSorceressBackWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\sorceress\\SOBWs.DC6";
- public static string CharacterSelectNecromancerUnselected = "data\\global\\ui\\FrontEnd\\necromancer\\NENU1.DC6";
- public static string CharacterSelectNecromancerUnselectedH = "data\\global\\ui\\FrontEnd\\necromancer\\NENU2.DC6";
- public static string CharacterSelecNecromancerSelected = "data\\global\\ui\\FrontEnd\\necromancer\\NENU3.DC6";
- public static string CharacterSelecNecromancerSelectedOverlay = "data\\global\\ui\\FrontEnd\\necromancer\\NENU3s.DC6";
- public static string CharacterSelecNecromancerForwardWalk = "data\\global\\ui\\FrontEnd\\necromancer\\NEFW.DC6";
- public static string CharacterSelecNecromancerForwardWalkOverlay = "data\\global\\ui\\FrontEnd\\necromancer\\NEFWs.DC6";
- public static string CharacterSelecNecromancerBackWalk = "data\\global\\ui\\FrontEnd\\necromancer\\NEBW.DC6";
- public static string CharacterSelecNecromancerBackWalkOverlay = "data\\global\\ui\\FrontEnd\\necromancer\\NEBWs.DC6";
+ public static string CharacterSelectNecromancerUnselected { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NENU1.DC6";
+ public static string CharacterSelectNecromancerUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NENU2.DC6";
+ public static string CharacterSelecNecromancerSelected { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NENU3.DC6";
+ public static string CharacterSelecNecromancerSelectedOverlay { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NENU3s.DC6";
+ public static string CharacterSelecNecromancerForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NEFW.DC6";
+ public static string CharacterSelecNecromancerForwardWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NEFWs.DC6";
+ public static string CharacterSelecNecromancerBackWalk { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NEBW.DC6";
+ public static string CharacterSelecNecromancerBackWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\necromancer\\NEBWs.DC6";
- public static string CharacterSelectPaladinUnselected = "data\\global\\ui\\FrontEnd\\paladin\\PANU1.DC6";
- public static string CharacterSelectPaladinUnselectedH = "data\\global\\ui\\FrontEnd\\paladin\\PANU2.DC6";
- public static string CharacterSelecPaladinSelected = "data\\global\\ui\\FrontEnd\\paladin\\PANU3.DC6";
- public static string CharacterSelecPaladinForwardWalk = "data\\global\\ui\\FrontEnd\\paladin\\PAFW.DC6";
- public static string CharacterSelecPaladinForwardWalkOverlay = "data\\global\\ui\\FrontEnd\\paladin\\PAFWs.DC6";
- public static string CharacterSelecPaladinBackWalk = "data\\global\\ui\\FrontEnd\\paladin\\PABW.DC6";
+ public static string CharacterSelectPaladinUnselected { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PANU1.DC6";
+ public static string CharacterSelectPaladinUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PANU2.DC6";
+ public static string CharacterSelecPaladinSelected { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PANU3.DC6";
+ public static string CharacterSelecPaladinForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PAFW.DC6";
+ public static string CharacterSelecPaladinForwardWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PAFWs.DC6";
+ public static string CharacterSelecPaladinBackWalk { get; } = "data\\global\\ui\\FrontEnd\\paladin\\PABW.DC6";
- public static string CharacterSelectAmazonUnselected = "data\\global\\ui\\FrontEnd\\amazon\\AMNU1.DC6";
- public static string CharacterSelectAmazonUnselectedH = "data\\global\\ui\\FrontEnd\\amazon\\AMNU2.DC6";
- public static string CharacterSelecAmazonSelected = "data\\global\\ui\\FrontEnd\\amazon\\AMNU3.DC6";
- public static string CharacterSelecAmazonForwardWalk = "data\\global\\ui\\FrontEnd\\amazon\\AMFW.DC6";
- public static string CharacterSelecAmazonForwardWalkOverlay = "data\\global\\ui\\FrontEnd\\amazon\\AMFWs.DC6";
- public static string CharacterSelecAmazonBackWalk = "data\\global\\ui\\FrontEnd\\amazon\\AMBW.DC6";
+ public static string CharacterSelectAmazonUnselected { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMNU1.DC6";
+ public static string CharacterSelectAmazonUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMNU2.DC6";
+ public static string CharacterSelecAmazonSelected { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMNU3.DC6";
+ public static string CharacterSelecAmazonForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMFW.DC6";
+ public static string CharacterSelecAmazonForwardWalkOverlay { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMFWs.DC6";
+ public static string CharacterSelecAmazonBackWalk { get; } = "data\\global\\ui\\FrontEnd\\amazon\\AMBW.DC6";
- public static string CharacterSelectAssassinUnselected = "data\\global\\ui\\FrontEnd\\assassin\\ASNU1.DC6";
- public static string CharacterSelectAssassinUnselectedH = "data\\global\\ui\\FrontEnd\\assassin\\ASNU2.DC6";
- public static string CharacterSelectAssassinSelected = "data\\global\\ui\\FrontEnd\\assassin\\ASNU3.DC6";
- public static string CharacterSelectAssassinForwardWalk = "data\\global\\ui\\FrontEnd\\assassin\\ASFW.DC6";
- public static string CharacterSelectAssassinBackWalk = "data\\global\\ui\\FrontEnd\\assassin\\ASBW.DC6";
+ public static string CharacterSelectAssassinUnselected { get; } = "data\\global\\ui\\FrontEnd\\assassin\\ASNU1.DC6";
+ public static string CharacterSelectAssassinUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\assassin\\ASNU2.DC6";
+ public static string CharacterSelectAssassinSelected { get; } = "data\\global\\ui\\FrontEnd\\assassin\\ASNU3.DC6";
+ public static string CharacterSelectAssassinForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\assassin\\ASFW.DC6";
+ public static string CharacterSelectAssassinBackWalk { get; } = "data\\global\\ui\\FrontEnd\\assassin\\ASBW.DC6";
- public static string CharacterSelectDruidUnselected = "data\\global\\ui\\FrontEnd\\druid\\DZNU1.dc6";
- public static string CharacterSelectDruidUnselectedH = "data\\global\\ui\\FrontEnd\\druid\\DZNU2.dc6";
- public static string CharacterSelectDruidSelected = "data\\global\\ui\\FrontEnd\\druid\\DZNU3.DC6";
- public static string CharacterSelectDruidForwardWalk = "data\\global\\ui\\FrontEnd\\druid\\DZFW.DC6";
- public static string CharacterSelectDruidBackWalk = "data\\global\\ui\\FrontEnd\\druid\\DZBW.DC6";
+ public static string CharacterSelectDruidUnselected { get; } = "data\\global\\ui\\FrontEnd\\druid\\DZNU1.dc6";
+ public static string CharacterSelectDruidUnselectedH { get; } = "data\\global\\ui\\FrontEnd\\druid\\DZNU2.dc6";
+ public static string CharacterSelectDruidSelected { get; } = "data\\global\\ui\\FrontEnd\\druid\\DZNU3.DC6";
+ public static string CharacterSelectDruidForwardWalk { get; } = "data\\global\\ui\\FrontEnd\\druid\\DZFW.DC6";
+ public static string CharacterSelectDruidBackWalk { get; } = "data\\global\\ui\\FrontEnd\\druid\\DZBW.DC6";
// -- Character Selection
- public static string CharacterSelectionBackground = "data\\global\\ui\\CharSelect\\characterselectscreenEXP.dc6";
+ public static string CharacterSelectionBackground { get; } = "data\\global\\ui\\CharSelect\\characterselectscreenEXP.dc6";
// --- Game ---
- public static string GamePanels = "data\\global\\ui\\PANEL\\800ctrlpnl7.dc6";
- public static string GameGlobeOverlap = "data\\global\\ui\\PANEL\\overlap.DC6";
- public static string HealthMana = "data\\global\\ui\\PANEL\\hlthmana.DC6";
- public static string GameSmallMenuButton = "data\\global\\ui\\PANEL\\menubutton.DC6"; // TODO: Used for inventory popout
- public static string SkillIcon = "data\\global\\ui\\PANEL\\Skillicon.DC6"; // TODO: Used for skill icon button
+ public static string GamePanels { get; } = "data\\global\\ui\\PANEL\\800ctrlpnl7.dc6";
+ public static string GameGlobeOverlap { get; } = "data\\global\\ui\\PANEL\\overlap.DC6";
+ public static string HealthMana { get; } = "data\\global\\ui\\PANEL\\hlthmana.DC6";
+ public static string GameSmallMenuButton { get; } = "data\\global\\ui\\PANEL\\menubutton.DC6"; // TODO: Used for inventory popout
+ public static string SkillIcon { get; } = "data\\global\\ui\\PANEL\\Skillicon.DC6"; // TODO: Used for skill icon button
// --- Mouse Pointers ---
- public static string CursorDefault = "data\\global\\ui\\CURSOR\\ohand.DC6";
+ public static string CursorDefault { get; } = "data\\global\\ui\\CURSOR\\ohand.DC6";
// --- Fonts ---
- public static string Font6 = "data\\local\\font\\latin\\font6";
- public static string Font8 = "data\\local\\font\\latin\\font8";
- public static string Font16 = "data\\local\\font\\latin\\font16";
- public static string Font24 = "data\\local\\font\\latin\\font24";
- public static string Font30 = "data\\local\\font\\latin\\font30";
- public static string FontFormal12 = "data\\local\\font\\latin\\fontformal12";
- public static string FontFormal11 = "data\\local\\font\\latin\\fontformal11";
- public static string FontFormal10 = "data\\local\\font\\latin\\fontformal10";
- public static string FontExocet10 = "data\\local\\font\\latin\\fontexocet10";
- public static string FontExocet8 = "data\\local\\font\\latin\\fontexocet8";
+ public static string Font6 { get; } = "data\\local\\font\\latin\\font6";
+ public static string Font8 { get; } = "data\\local\\font\\latin\\font8";
+ public static string Font16 { get; } = "data\\local\\font\\latin\\font16";
+ public static string Font24 { get; } = "data\\local\\font\\latin\\font24";
+ public static string Font30 { get; } = "data\\local\\font\\latin\\font30";
+ public static string FontFormal12 { get; } = "data\\local\\font\\latin\\fontformal12";
+ public static string FontFormal11 { get; } = "data\\local\\font\\latin\\fontformal11";
+ public static string FontFormal10 { get; } = "data\\local\\font\\latin\\fontformal10";
+ public static string FontExocet10 { get; } = "data\\local\\font\\latin\\fontexocet10";
+ public static string FontExocet8 { get; } = "data\\local\\font\\latin\\fontexocet8";
// --- UI ---
- public static string WideButtonBlank = "data\\global\\ui\\FrontEnd\\WideButtonBlank.dc6";
- public static string MediumButtonBlank = "data\\global\\ui\\FrontEnd\\MediumButtonBlank.dc6";
- public static string CancelButton = "data\\global\\ui\\FrontEnd\\CancelButtonBlank.dc6";
- public static string NarrowButtonBlank = "data\\global\\ui\\FrontEnd\\NarrowButtonBlank.dc6";
- public static string TextBox2 = "data\\global\\ui\\FrontEnd\\textbox2.dc6";
- public static string TallButtonBlank = "data\\global\\ui\\CharSelect\\TallButtonBlank.dc6";
+ public static string WideButtonBlank { get; } = "data\\global\\ui\\FrontEnd\\WideButtonBlank.dc6";
+ public static string MediumButtonBlank { get; } = "data\\global\\ui\\FrontEnd\\MediumButtonBlank.dc6";
+ public static string CancelButton { get; } = "data\\global\\ui\\FrontEnd\\CancelButtonBlank.dc6";
+ public static string NarrowButtonBlank { get; } = "data\\global\\ui\\FrontEnd\\NarrowButtonBlank.dc6";
+ public static string TextBox2 { get; } = "data\\global\\ui\\FrontEnd\\textbox2.dc6";
+ public static string TallButtonBlank { get; } = "data\\global\\ui\\CharSelect\\TallButtonBlank.dc6";
// --- GAME UI ---
- public static string MinipanelSmall = "data\\global\\ui\\PANEL\\minipanel_s.dc6";
- public static string MinipanelButton = "data\\global\\ui\\PANEL\\minipanelbtn.DC6";
+ public static string MinipanelSmall { get; } = "data\\global\\ui\\PANEL\\minipanel_s.dc6";
+ public static string MinipanelButton { get; } = "data\\global\\ui\\PANEL\\minipanelbtn.DC6";
- public static string Frame = "data\\global\\ui\\PANEL\\800borderframe.dc6";
- public static string InventoryCharacterPanel = "data\\global\\ui\\PANEL\\invchar.DC6";
+ public static string Frame { get; } = "data\\global\\ui\\PANEL\\800borderframe.dc6";
+ public static string InventoryCharacterPanel { get; } = "data\\global\\ui\\PANEL\\invchar.DC6";
- public static string RunButton = "data\\global\\ui\\PANEL\\runbutton.dc6";
- public static string MenuButton = "data\\global\\ui\\PANEL\\menubutton.DC6";
+ public static string RunButton { get; } = "data\\global\\ui\\PANEL\\runbutton.dc6";
+ public static string MenuButton { get; } = "data\\global\\ui\\PANEL\\menubutton.DC6";
- public static string ArmorPlaceholder = "data\\global\\ui\\PANEL\\inv_armor.DC6";
- public static string BeltPlaceholder = "data\\global\\ui\\PANEL\\inv_belt.DC6";
- public static string BootsPlaceholder = "data\\global\\ui\\PANEL\\inv_boots.DC6";
- public static string HelmGlovePlaceholder = "data\\global\\ui\\PANEL\\inv_helm_glove.DC6";
- public static string RingAmuletPlaceholder = "data\\global\\ui\\PANEL\\inv_ring_amulet.DC6";
- public static string WeaponsPlaceholder = "data\\global\\ui\\PANEL\\inv_weapons.DC6";
+ public static string ArmorPlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_armor.DC6";
+ public static string BeltPlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_belt.DC6";
+ public static string BootsPlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_boots.DC6";
+ public static string HelmGlovePlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_helm_glove.DC6";
+ public static string RingAmuletPlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_ring_amulet.DC6";
+ public static string WeaponsPlaceholder { get; } = "data\\global\\ui\\PANEL\\inv_weapons.DC6";
// --- Data ---
// TODO: Doesn't sound right :)
- public static string EnglishTable = "data\\local\\lng\\eng\\English.txt";
- public static string ExpansionStringTable = "data\\local\\lng\\eng\\expansionstring.tbl";
- public static string LevelPreset = "data\\global\\excel\\LvlPrest.txt";
- public static string LevelType = "data\\global\\excel\\LvlTypes.txt";
- public static string LevelDetails = "data\\global\\excel\\Levels.txt";
+ public static string EnglishTable { get; } = "data\\local\\lng\\eng\\English.txt";
+ public static string ExpansionStringTable { get; } = "data\\local\\lng\\eng\\expansionstring.tbl";
+ public static string LevelPreset { get; } = "data\\global\\excel\\LvlPrest.txt";
+ public static string LevelType { get; } = "data\\global\\excel\\LvlTypes.txt";
+ public static string LevelDetails { get; } = "data\\global\\excel\\Levels.txt";
// --- Animations ---
- public static string ObjectData = "data\\global\\objects";
- public static string AnimationData = "data\\global\\animdata.d2";
- public static string PlayerAnimationBase = "data\\global\\CHARS";
+ public static string ObjectData { get; } = "data\\global\\objects";
+ public static string AnimationData { get; } = "data\\global\\animdata.d2";
+ public static string PlayerAnimationBase { get; } = "data\\global\\CHARS";
// --- Inventory Data ---
- public static string Weapons = "data\\global\\excel\\weapons.txt";
- public static string Armor = "data\\global\\excel\\armor.txt";
- public static string Misc = "data\\global\\excel\\misc.txt";
+ public static string Weapons { get; } = "data\\global\\excel\\weapons.txt";
+ public static string Armor { get; } = "data\\global\\excel\\armor.txt";
+ public static string Misc { get; } = "data\\global\\excel\\misc.txt";
// --- Character Data ---
- public static string Experience = "data\\global\\excel\\experience.txt";
- public static string CharStats = "data\\global\\excel\\charstats.txt";
+ public static string Experience { get; } = "data\\global\\excel\\experience.txt";
+ public static string CharStats { get; } = "data\\global\\excel\\charstats.txt";
public static string GeneratePathForItem(string spriteName)
{
diff --git a/OpenDiablo2.Core.UT/UT_MobManager.cs b/OpenDiablo2.Core.UT/UT_MobManager.cs
index 72fa6f12..a388550d 100644
--- a/OpenDiablo2.Core.UT/UT_MobManager.cs
+++ b/OpenDiablo2.Core.UT/UT_MobManager.cs
@@ -28,7 +28,7 @@ namespace OpenDiablo2.Core.UT
Assert.IsTrue(mobman.Mobs.Count(x => x.HasFlag(eMobFlags.ENEMY)) == 2);
Assert.IsTrue(mobman.Mobs.Count(x => x.HasFlag(eMobFlags.INVULNERABLE)) == 1);
- Assert.IsTrue(mobman.Mobs.Count(x => x.HasFlag(eMobFlags.PLAYER)) == 0);
+ Assert.IsTrue(!mobman.Mobs.Any(x => x.HasFlag(eMobFlags.PLAYER)));
Assert.IsTrue(mobman.Mobs.Count(x => !x.HasFlag(eMobFlags.PLAYER)) == 3);
}
diff --git a/OpenDiablo2.Core/EngineDataManager.cs b/OpenDiablo2.Core/EngineDataManager.cs
index 7a9d291b..bb08e468 100644
--- a/OpenDiablo2.Core/EngineDataManager.cs
+++ b/OpenDiablo2.Core/EngineDataManager.cs
@@ -47,7 +47,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
.Where(x => x.Count() == 36 && x[0] != "Expansion")
- .ToArray()
.Select(x => x.ToLevelType());
LevelTypes = new List(data);
@@ -62,7 +61,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
.Where(x => x.Count() == 24 && x[0] != "Expansion")
- .ToArray()
.Select(x => x.ToLevelPreset());
LevelPresets = new List(data);
@@ -77,7 +75,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
.Where(x => x.Count() > 80 && x[0] != "Expansion")
- .ToArray()
.Select(x => x.ToLevelDetail());
LevelDetails = new List(data);
@@ -102,11 +99,9 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
- .ToArray()
.Select(x => x.ToWeapon());
return data;
- ;
}
private IEnumerable LoadArmorData()
@@ -117,7 +112,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
- .ToArray()
.Select(x => x.ToArmor());
return data;
@@ -131,7 +125,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
//.Where(x => !String.IsNullOrWhiteSpace(x[27]))
- .ToArray()
.Select(x => x.ToMisc());
return data;
@@ -163,7 +156,6 @@ namespace OpenDiablo2.Core
.Where(x => !String.IsNullOrWhiteSpace(x))
.Select(x => x.Split('\t'))
.Where(x => x[0] != "Expansion")
- .ToArray()
.ToDictionary(x => (eHero)Enum.Parse(typeof(eHero),x[0]), x => x.ToHeroTypeConfig());
HeroTypeConfigs = data;
diff --git a/OpenDiablo2.Core/GameState/GameState.cs b/OpenDiablo2.Core/GameState/GameState.cs
index cba1122f..47cab185 100644
--- a/OpenDiablo2.Core/GameState/GameState.cs
+++ b/OpenDiablo2.Core/GameState/GameState.cs
@@ -106,7 +106,7 @@ namespace OpenDiablo2.Core.GameState_
{
log.Info($"Setting seed to {seed}");
this.Seed = seed;
- (new MapGenerator(this)).Generate();
+ new MapGenerator(this).Generate();
}
public MapInfo LoadSubMap(int levelDefId, Point origin)
@@ -126,7 +126,7 @@ namespace OpenDiablo2.Core.GameState_
var random = new Random(Seed);
- var mapName = "data\\global\\tiles\\" + mapNames[random.Next(mapNames.Count())].Replace("/", "\\");
+ var mapName = "data\\global\\tiles\\" + mapNames[random.Next(mapNames.Count)].Replace("/", "\\");
var fileData = resourceManager.GetMPQDS1(mapName, level, levelDetails, levelType);
var result = new MapInfo
@@ -162,7 +162,7 @@ namespace OpenDiablo2.Core.GameState_
var random = new Random(Seed);
- var mapName = "data\\global\\tiles\\" + mapNames[random.Next(mapNames.Count())].Replace("/", "\\");
+ var mapName = "data\\global\\tiles\\" + mapNames[random.Next(mapNames.Count)].Replace("/", "\\");
MapName = level.Name;
Act = levelType.Act;
@@ -238,10 +238,12 @@ namespace OpenDiablo2.Core.GameState_
public void SelectItem(Item item)
{
- if(item == null)
+ if (item == null)
{
renderWindow.MouseCursor = this.originalMouseCursor;
- } else {
+ }
+ else
+ {
var cursorsprite = renderWindow.LoadSprite(ResourcePaths.GeneratePathForItem(item.InvFile), Palettes.Units);
renderWindow.MouseCursor = renderWindow.LoadCursor(cursorsprite, 0, new Point(cursorsprite.FrameSize.Width / 2, cursorsprite.FrameSize.Height / 2));
@@ -266,14 +268,11 @@ namespace OpenDiablo2.Core.GameState_
var main_index = (props.Prop3 >> 4) + ((props.Prop4 & 0x03) << 4);
var orientation = 0;
- if (cellType == eRenderCellType.Floor)
+ // Floors can't have rotations, should we blow up here?
+ if (cellType == eRenderCellType.Floor && props.Prop1 == 0)
{
- // Floors can't have rotations, should we blow up here?
- if (props.Prop1 == 0)
- {
- map.CellInfo[cellType][cellX + (cellY * map.FileData.Width)] = new MapCellInfo { Ignore = true };
- return null;
- }
+ map.CellInfo[cellType][cellX + (cellY * map.FileData.Width)] = new MapCellInfo { Ignore = true };
+ return null;
}
if (cellType == eRenderCellType.Roof)
@@ -420,7 +419,7 @@ namespace OpenDiablo2.Core.GameState_
public void Update(long ms)
{
- animationTime += ((float)ms / 1000f);
+ animationTime += (float)ms / 1000f;
animationTime -= (float)Math.Truncate(animationTime);
var seconds = ms / 1000f;
diff --git a/OpenDiablo2.Core/Map Engine/MapGenerator.cs b/OpenDiablo2.Core/Map Engine/MapGenerator.cs
index 796b1122..68697a0a 100644
--- a/OpenDiablo2.Core/Map Engine/MapGenerator.cs
+++ b/OpenDiablo2.Core/Map Engine/MapGenerator.cs
@@ -54,10 +54,10 @@ namespace OpenDiablo2.Core.Map_Engine
}
// Generate the Blood Moore?
- for (var y = 0; y < (bloodMooreRect.Height); y+= 8)
+ for (var y = 0; y < bloodMooreRect.Height; y+= 8)
{
- for (var x = 0; x < (bloodMooreRect.Width); x += 8)
+ for (var x = 0; x < bloodMooreRect.Width; x += 8)
{
var tileIdx = 35;
var mapTile = gameState.LoadSubMap(tileIdx, new Point(bloodMooreRect.Left + x, bloodMooreRect.Top + y));
diff --git a/OpenDiablo2.Core/UI/Button.cs b/OpenDiablo2.Core/UI/Button.cs
index a36a1edd..2610c1c4 100644
--- a/OpenDiablo2.Core/UI/Button.cs
+++ b/OpenDiablo2.Core/UI/Button.cs
@@ -129,8 +129,8 @@ namespace OpenDiablo2.Core.UI
return;
}
- var hovered = (mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + buttonWidth))
- && (mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + buttonHeight));
+ var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + buttonWidth)
+ && mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + buttonHeight);
if (!activeLock && hovered && mouseInfoProvider.LeftMouseDown && !mouseInfoProvider.ReserveMouse)
@@ -165,7 +165,7 @@ namespace OpenDiablo2.Core.UI
activeLock = false;
}
- pressed = (hovered && mouseInfoProvider.LeftMouseDown && active);
+ pressed = hovered && mouseInfoProvider.LeftMouseDown && active;
}
public void Render()
diff --git a/OpenDiablo2.Core/UI/ItemContainer.cs b/OpenDiablo2.Core/UI/ItemContainer.cs
index c6f59205..e1866ca6 100644
--- a/OpenDiablo2.Core/UI/ItemContainer.cs
+++ b/OpenDiablo2.Core/UI/ItemContainer.cs
@@ -65,8 +65,8 @@ namespace OpenDiablo2.Core.UI
public void Update()
{
- var hovered = (mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width))
- && (mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height));
+ var hovered = mouseInfoProvider.MouseX >= location.X && mouseInfoProvider.MouseX < (location.X + this.Size.Width)
+ && mouseInfoProvider.MouseY >= location.Y && mouseInfoProvider.MouseY < (location.Y + this.Size.Height);
if (hovered && mouseInfoProvider.LeftMousePressed)
{
diff --git a/OpenDiablo2.GameServer/GameServer.cs b/OpenDiablo2.GameServer/GameServer.cs
index 8af4e340..c8ee0f33 100644
--- a/OpenDiablo2.GameServer/GameServer.cs
+++ b/OpenDiablo2.GameServer/GameServer.cs
@@ -28,7 +28,7 @@ namespace OpenDiablo2.GameServer_
public void InitializeNewGame()
{
log.Info("Initializing a new game");
- Seed = (new Random()).Next();
+ Seed = new Random().Next();
}
public int SpawnNewPlayer(int clientHash, string playerName, eHero heroType)
diff --git a/OpenDiablo2.SDL2/CS-SDL/SDL2.cs b/OpenDiablo2.SDL2/CS-SDL/SDL2.cs
index e0f28463..742e4bd9 100644
--- a/OpenDiablo2.SDL2/CS-SDL/SDL2.cs
+++ b/OpenDiablo2.SDL2/CS-SDL/SDL2.cs
@@ -203,11 +203,11 @@ namespace SDL2
public const uint SDL_INIT_EVENTS = 0x00004000;
public const uint SDL_INIT_SENSOR = 0x00008000;
public const uint SDL_INIT_NOPARACHUTE = 0x00100000;
- public const uint SDL_INIT_EVERYTHING = (
+ public const uint SDL_INIT_EVERYTHING =
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |
SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC |
SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR
- );
+ ;
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int SDL_Init(uint flags);
@@ -934,7 +934,7 @@ namespace SDL2
public static bool SDL_VERSION_ATLEAST(int X, int Y, int Z)
{
- return (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z));
+ return SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z);
}
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
@@ -1054,7 +1054,7 @@ namespace SDL2
SDL_WINDOW_INPUT_FOCUS = 0x00000200,
SDL_WINDOW_MOUSE_FOCUS = 0x00000400,
SDL_WINDOW_FULLSCREEN_DESKTOP =
- (SDL_WINDOW_FULLSCREEN | 0x00001000),
+ SDL_WINDOW_FULLSCREEN | 0x00001000,
SDL_WINDOW_FOREIGN = 0x00000800,
SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /* Only available in 2.0.1 */
SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /* Only available in 2.0.4 */
@@ -1088,7 +1088,7 @@ namespace SDL2
public static int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int X)
{
- return (SDL_WINDOWPOS_UNDEFINED_MASK | X);
+ return SDL_WINDOWPOS_UNDEFINED_MASK | X;
}
public static bool SDL_WINDOWPOS_ISUNDEFINED(int X)
@@ -1098,7 +1098,7 @@ namespace SDL2
public static int SDL_WINDOWPOS_CENTERED_DISPLAY(int X)
{
- return (SDL_WINDOWPOS_CENTERED_MASK | X);
+ return SDL_WINDOWPOS_CENTERED_MASK | X;
}
public static bool SDL_WINDOWPOS_ISCENTERED(int X)
@@ -2535,11 +2535,11 @@ namespace SDL2
}
SDL_PIXELTYPE_ENUM pType =
(SDL_PIXELTYPE_ENUM) SDL_PIXELTYPE(format);
- return (
+ return
pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX1 ||
pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX4 ||
pType == SDL_PIXELTYPE_ENUM.SDL_PIXELTYPE_INDEX8
- );
+ ;
}
public static bool SDL_ISPIXELFORMAT_ALPHA(uint format)
@@ -2550,12 +2550,12 @@ namespace SDL2
}
SDL_PIXELORDER_ENUM pOrder =
(SDL_PIXELORDER_ENUM) SDL_PIXELORDER(format);
- return (
+ return
pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ARGB ||
pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_RGBA ||
pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_ABGR ||
pOrder == SDL_PIXELORDER_ENUM.SDL_PACKEDORDER_BGRA
- );
+ ;
}
public static bool SDL_ISPIXELFORMAT_FOURCC(uint format)
@@ -4498,7 +4498,7 @@ namespace SDL2
#region SDL_keycode.h
- public const int SDLK_SCANCODE_MASK = (1 << 30);
+ public const int SDLK_SCANCODE_MASK = 1 << 30;
public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X)
{
return (SDL_Keycode)((int)X | SDLK_SCANCODE_MASK);
@@ -4794,10 +4794,10 @@ namespace SDL2
KMOD_RESERVED = 0x8000,
/* These are defines in the SDL headers */
- KMOD_CTRL = (KMOD_LCTRL | KMOD_RCTRL),
- KMOD_SHIFT = (KMOD_LSHIFT | KMOD_RSHIFT),
- KMOD_ALT = (KMOD_LALT | KMOD_RALT),
- KMOD_GUI = (KMOD_LGUI | KMOD_RGUI)
+ KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL,
+ KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT,
+ KMOD_ALT = KMOD_LALT | KMOD_RALT,
+ KMOD_GUI = KMOD_LGUI | KMOD_RGUI
}
#endregion
@@ -5738,21 +5738,21 @@ namespace SDL2
#region SDL_haptic.h
/* SDL_HapticEffect type */
- public const ushort SDL_HAPTIC_CONSTANT = (1 << 0);
- public const ushort SDL_HAPTIC_SINE = (1 << 1);
- public const ushort SDL_HAPTIC_LEFTRIGHT = (1 << 2);
- public const ushort SDL_HAPTIC_TRIANGLE = (1 << 3);
- public const ushort SDL_HAPTIC_SAWTOOTHUP = (1 << 4);
- public const ushort SDL_HAPTIC_SAWTOOTHDOWN = (1 << 5);
- public const ushort SDL_HAPTIC_SPRING = (1 << 7);
- public const ushort SDL_HAPTIC_DAMPER = (1 << 8);
- public const ushort SDL_HAPTIC_INERTIA = (1 << 9);
- public const ushort SDL_HAPTIC_FRICTION = (1 << 10);
- public const ushort SDL_HAPTIC_CUSTOM = (1 << 11);
- public const ushort SDL_HAPTIC_GAIN = (1 << 12);
- public const ushort SDL_HAPTIC_AUTOCENTER = (1 << 13);
- public const ushort SDL_HAPTIC_STATUS = (1 << 14);
- public const ushort SDL_HAPTIC_PAUSE = (1 << 15);
+ public const ushort SDL_HAPTIC_CONSTANT = 1 << 0;
+ public const ushort SDL_HAPTIC_SINE = 1 << 1;
+ public const ushort SDL_HAPTIC_LEFTRIGHT = 1 << 2;
+ public const ushort SDL_HAPTIC_TRIANGLE = 1 << 3;
+ public const ushort SDL_HAPTIC_SAWTOOTHUP = 1 << 4;
+ public const ushort SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5;
+ public const ushort SDL_HAPTIC_SPRING = 1 << 7;
+ public const ushort SDL_HAPTIC_DAMPER = 1 << 8;
+ public const ushort SDL_HAPTIC_INERTIA = 1 << 9;
+ public const ushort SDL_HAPTIC_FRICTION = 1 << 10;
+ public const ushort SDL_HAPTIC_CUSTOM = 1 << 11;
+ public const ushort SDL_HAPTIC_GAIN = 1 << 12;
+ public const ushort SDL_HAPTIC_AUTOCENTER = 1 << 13;
+ public const ushort SDL_HAPTIC_STATUS = 1 << 14;
+ public const ushort SDL_HAPTIC_PAUSE = 1 << 15;
/* SDL_HapticDirection type */
public const byte SDL_HAPTIC_POLAR = 0;
@@ -6153,9 +6153,9 @@ namespace SDL2
#region SDL_audio.h
public const ushort SDL_AUDIO_MASK_BITSIZE = 0xFF;
- public const ushort SDL_AUDIO_MASK_DATATYPE = (1 << 8);
- public const ushort SDL_AUDIO_MASK_ENDIAN = (1 << 12);
- public const ushort SDL_AUDIO_MASK_SIGNED = (1 << 15);
+ public const ushort SDL_AUDIO_MASK_DATATYPE = 1 << 8;
+ public const ushort SDL_AUDIO_MASK_ENDIAN = 1 << 12;
+ public const ushort SDL_AUDIO_MASK_SIGNED = 1 << 15;
public static ushort SDL_AUDIO_BITSIZE(ushort x)
{
@@ -6220,12 +6220,12 @@ namespace SDL2
public const uint SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002;
public const uint SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004;
public const uint SDL_AUDIO_ALLOW_SAMPLES_CHANGE = 0x00000008;
- public const uint SDL_AUDIO_ALLOW_ANY_CHANGE = (
+ public const uint SDL_AUDIO_ALLOW_ANY_CHANGE =
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
SDL_AUDIO_ALLOW_FORMAT_CHANGE |
SDL_AUDIO_ALLOW_CHANNELS_CHANGE |
SDL_AUDIO_ALLOW_SAMPLES_CHANGE
- );
+ ;
public const int SDL_MIX_MAXVOLUME = 128;
@@ -6535,7 +6535,7 @@ namespace SDL2
*/
public static bool SDL_TICKS_PASSED(UInt32 A, UInt32 B)
{
- return ((Int32)(B - A) <= 0);
+ return (Int32)(B - A) <= 0;
}
/* Delays the thread's processing based on the milliseconds parameter */
diff --git a/OpenDiablo2.SDL2/SDL2CharacterRenderer.cs b/OpenDiablo2.SDL2/SDL2CharacterRenderer.cs
index 1193297d..0e42df69 100644
--- a/OpenDiablo2.SDL2/SDL2CharacterRenderer.cs
+++ b/OpenDiablo2.SDL2/SDL2CharacterRenderer.cs
@@ -91,8 +91,8 @@ namespace OpenDiablo2.SDL2_
if (currentDirectionCache == null)
return;
- seconds += ((float)ms / 1000f);
- var animationSeg = (15f / (float)currentDirectionCache.AnimationSpeed);
+ seconds += (float)ms / 1000f;
+ var animationSeg = 15f / (float)currentDirectionCache.AnimationSpeed;
while (seconds >= animationSeg)
{
seconds -= animationSeg;
diff --git a/OpenDiablo2.SDL2/SDL2Label.cs b/OpenDiablo2.SDL2/SDL2Label.cs
index 02cfd48f..c80dbaa9 100644
--- a/OpenDiablo2.SDL2/SDL2Label.cs
+++ b/OpenDiablo2.SDL2/SDL2Label.cs
@@ -85,7 +85,7 @@ namespace OpenDiablo2.SDL2_
return new Size(w, h);
}
- if (MaxWidth < (font.sprite.FrameSize.Width))
+ if (MaxWidth < font.sprite.FrameSize.Width)
throw new OpenDiablo2Exception("Max label width cannot be smaller than a single character.");
var lastWordIndex = 0;
@@ -181,7 +181,7 @@ namespace OpenDiablo2.SDL2_
var y = 0;
foreach(var line in linesToRender)
{
- var lineWidth = (line.Sum(c => font.font.CharacterMetric[c].Width));
+ var lineWidth = line.Sum(c => font.font.CharacterMetric[c].Width);
var x = 0;
if (Alignment == eTextAlign.Centered)
diff --git a/OpenDiablo2.SDL2/SDL2RenderWindow.cs b/OpenDiablo2.SDL2/SDL2RenderWindow.cs
index 785c844d..2f649cce 100644
--- a/OpenDiablo2.SDL2/SDL2RenderWindow.cs
+++ b/OpenDiablo2.SDL2/SDL2RenderWindow.cs
@@ -373,7 +373,7 @@ namespace OpenDiablo2.SDL2_
{
UInt32* data = (UInt32*)pixels;
- var pitchChange = (pitch / 4);
+ var pitchChange = pitch / 4;
for (var i = 0; i < frameSize.Height * pitchChange; i++)
data[i] = 0x0;
diff --git a/OpenDiablo2.SDL2/SDL2Sprite.cs b/OpenDiablo2.SDL2/SDL2Sprite.cs
index 14078568..8b088953 100644
--- a/OpenDiablo2.SDL2/SDL2Sprite.cs
+++ b/OpenDiablo2.SDL2/SDL2Sprite.cs
@@ -102,7 +102,7 @@ namespace OpenDiablo2.SDL2_
{
return source == null
? Location
- : new Point(Location.X + source.Frames[Frame].OffsetX, (Location.Y - FrameSize.Height) + source.Frames[Frame].OffsetY);
+ : new Point(Location.X + source.Frames[Frame].OffsetX, Location.Y - FrameSize.Height + source.Frames[Frame].OffsetY);
}
public Size LocalFrameSize => new Size((int)source.Frames[Frame].Width, (int)source.Frames[Frame].Height);
diff --git a/OpenDiablo2.Scenes/Game.cs b/OpenDiablo2.Scenes/Game.cs
index 876bd2ec..a4f0e1fd 100644
--- a/OpenDiablo2.Scenes/Game.cs
+++ b/OpenDiablo2.Scenes/Game.cs
@@ -68,8 +68,8 @@ namespace OpenDiablo2.Scenes
if (gameHUD.IsMouseOver())
return;
- var mx = (mouseInfoProvider.MouseX - 400) - gameState.CameraOffset;
- var my = (mouseInfoProvider.MouseY - 300);
+ var mx = mouseInfoProvider.MouseX - 400 - gameState.CameraOffset;
+ var my = mouseInfoProvider.MouseY - 300;
var tx = (mx / 60f + my / 40f) / 2f;
var ty = (my / 40f - (mx / 60f)) / 2f;
diff --git a/OpenDiablo2.Scenes/MainMenu.cs b/OpenDiablo2.Scenes/MainMenu.cs
index d7628eaf..fcaec185 100644
--- a/OpenDiablo2.Scenes/MainMenu.cs
+++ b/OpenDiablo2.Scenes/MainMenu.cs
@@ -107,7 +107,7 @@ namespace OpenDiablo2.Scenes
public void Update(long ms)
{
- float seconds = ((float)ms / 1000f);
+ float seconds = (float)ms / 1000f;
logoFrame += seconds;
while (logoFrame >= 1f)
logoFrame -= 1f;
diff --git a/OpenDiablo2.Scenes/SelectHeroClass.cs b/OpenDiablo2.Scenes/SelectHeroClass.cs
index a4471f75..05417261 100644
--- a/OpenDiablo2.Scenes/SelectHeroClass.cs
+++ b/OpenDiablo2.Scenes/SelectHeroClass.cs
@@ -341,7 +341,7 @@ namespace OpenDiablo2.Scenes
public void Update(long ms)
{
- float seconds = ((float)ms / 1500f);
+ float seconds = (float)ms / 1500f;
secondTimer += seconds;
while (secondTimer >= 1f)
secondTimer -= 1f;
diff --git a/OpenDiablo2/Program.cs b/OpenDiablo2/Program.cs
index f7a217da..8191fc02 100644
--- a/OpenDiablo2/Program.cs
+++ b/OpenDiablo2/Program.cs
@@ -44,7 +44,7 @@ namespace OpenDiablo2
Parser.Default.ParseArguments(args).WithParsed(o => globalConfiguration = new GlobalConfiguration
{
BaseDataPath = Path.GetFullPath(o.DataPath ?? Directory.GetCurrentDirectory()),
- MouseMode = o.HardwareMouse == true ? eMouseMode.Hardware : eMouseMode.Software,
+ MouseMode = o.HardwareMouse ? eMouseMode.Hardware : eMouseMode.Software,
HardwareMouseScale = o.MouseScale,
FullScreen = o.FullScreen
}).WithNotParsed(o =>