Core: SOme code cleanup, more to follow.

This commit is contained in:
hondacrx
2021-03-20 22:48:48 -04:00
parent 62f554f2e0
commit 62ec699ec6
318 changed files with 5080 additions and 5125 deletions
@@ -159,7 +159,7 @@ namespace Game.DataStorage
case TypeCode.Object:
if (type == typeof(LocalizedString))
{
LocalizedString locString = new LocalizedString();
LocalizedString locString = new();
locString[Global.WorldMgr.GetDefaultDbcLocale()] = result.Read<string>(dbIndex++);
f.SetValue(obj, locString);
@@ -37,7 +37,7 @@ namespace Game.DataStorage
public static DB6Storage<T> Read<T>(BitSet availableDb2Locales, string db2Path, string fileName, HotfixStatements preparedStatement, HotfixStatements preparedStatementLocale, ref uint loadedFileCount) where T : new()
{
DB6Storage<T> storage = new DB6Storage<T>();
DB6Storage<T> storage = new();
if (!File.Exists(db2Path + fileName))
{
@@ -45,7 +45,7 @@ namespace Game.DataStorage
return storage;
}
DBReader reader = new DBReader();
DBReader reader = new();
using (var stream = new FileStream(db2Path + fileName, FileMode.Open))
{
if (!reader.Load(stream))
@@ -118,7 +118,7 @@ namespace Game.DataStorage
{
if (ColumnMeta[i].CompressionType == DB2ColumnCompression.Common)
{
Dictionary<int, Value32> commonValues = new Dictionary<int, Value32>();
Dictionary<int, Value32> commonValues = new();
CommonData[i] = commonValues;
for (int j = 0; j < ColumnMeta[i].AdditionalDataSize / 8; j++)
@@ -177,7 +177,7 @@ namespace Game.DataStorage
bool isIndexEmpty = Header.HasIndexTable() && indexData.Count(i => i == 0) == sections[sectionIndex].NumRecords;
// duplicate rows data
Dictionary<int, int> copyData = new Dictionary<int, int>();
Dictionary<int, int> copyData = new();
for (int i = 0; i < sections[sectionIndex].NumCopyRecords; i++)
copyData[reader.ReadInt32()] = reader.ReadInt32();
@@ -222,7 +222,7 @@ namespace Game.DataStorage
//indexData = sparseIndexData;
}
BitReader bitReader = new BitReader(recordsData);
BitReader bitReader = new(recordsData);
for (int i = 0; i < sections[sectionIndex].NumRecords; ++i)
{
@@ -262,7 +262,7 @@ namespace Game.DataStorage
internal Value32[][] PalletData;
internal Dictionary<int, Value32>[] CommonData;
Dictionary<int, WDC3Row> _records = new Dictionary<int, WDC3Row>();
Dictionary<int, WDC3Row> _records = new();
}
class WDC3Row
@@ -393,7 +393,7 @@ namespace Game.DataStorage
_data.Offset = _dataOffset;
int fieldIndex = 0;
T obj = new T();
T obj = new();
foreach (var f in typeof(T).GetFields())
{
@@ -533,7 +533,7 @@ namespace Game.DataStorage
case TypeCode.Object:
if (type == typeof(LocalizedString))
{
LocalizedString localized = new LocalizedString();
LocalizedString localized = new();
if (_stringsTable == null)
{
localized[Locale.enUS] = _data.ReadCString();
@@ -749,6 +749,6 @@ namespace Game.DataStorage
}
}
StringArray stringStorage = new StringArray((int)Locale.Total);
StringArray stringStorage = new((int)Locale.Total);
}
}
@@ -26,7 +26,7 @@ namespace Game.DataStorage
{
internal static GameTable<T> Read<T>(string path, string fileName, ref uint loadedFileCount) where T : new()
{
GameTable<T> storage = new GameTable<T>();
GameTable<T> storage = new();
if (!File.Exists(path + fileName))
{
@@ -42,7 +42,7 @@ namespace Game.DataStorage
return storage;
}
List<T> data = new List<T>();
List<T> data = new();
data.Add(new T()); // row id 0, unused
string line;
@@ -92,6 +92,6 @@ namespace Game.DataStorage
public void SetData(List<T> data) { _data = data; }
List<T> _data = new List<T>();
List<T> _data = new();
}
}