Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -35,21 +35,21 @@ namespace Server
if (!Enabled)
return;
string mapDataPath = Core.FindDataFile("mapdif{0}.mul", index);
string mapIndexPath = Core.FindDataFile("mapdifl{0}.mul", index);
var mapDataPath = Core.FindDataFile("mapdif{0}.mul", index);
var mapIndexPath = Core.FindDataFile("mapdifl{0}.mul", index);
if (File.Exists(mapDataPath) && File.Exists(mapIndexPath))
m_LandBlocks = PatchLand(matrix, mapDataPath, mapIndexPath);
string staDataPath = Core.FindDataFile("stadif{0}.mul", index);
string staIndexPath = Core.FindDataFile("stadifl{0}.mul", index);
string staLookupPath = Core.FindDataFile("stadifi{0}.mul", index);
var staDataPath = Core.FindDataFile("stadif{0}.mul", index);
var staIndexPath = Core.FindDataFile("stadifl{0}.mul", index);
var staLookupPath = Core.FindDataFile("stadifi{0}.mul", index);
if (File.Exists(staDataPath) && File.Exists(staIndexPath) && File.Exists(staLookupPath))
m_StaticBlocks = PatchStatics(matrix, staDataPath, staIndexPath, staLookupPath);
}
public static bool Enabled{ get; set; } = true;
public static bool Enabled { get; set; } = true;
public int LandBlocks
{
@ -76,21 +76,21 @@ namespace Server
[MethodImpl(MethodImplOptions.Synchronized)]
private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
{
using FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader indexReader = new BinaryReader(fsIndex);
using var fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
var indexReader = new BinaryReader(fsIndex);
int count = (int)(indexReader.BaseStream.Length / 4);
var count = (int)(indexReader.BaseStream.Length / 4);
for (int i = 0; i < count; ++i)
for (var i = 0; i < count; ++i)
{
int blockID = indexReader.ReadInt32();
int x = blockID / matrix.BlockHeight;
int y = blockID % matrix.BlockHeight;
var blockID = indexReader.ReadInt32();
var x = blockID / matrix.BlockHeight;
var y = blockID % matrix.BlockHeight;
fsData.Seek(4, SeekOrigin.Current);
LandTile[] tiles = new LandTile[64];
var tiles = new LandTile[64];
fixed (LandTile* pTiles = tiles)
{
@ -108,32 +108,32 @@ namespace Server
[MethodImpl(MethodImplOptions.Synchronized)]
private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath)
{
using FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using FileStream fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read);
BinaryReader indexReader = new BinaryReader(fsIndex);
BinaryReader lookupReader = new BinaryReader(fsLookup);
using var fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read);
var indexReader = new BinaryReader(fsIndex);
var lookupReader = new BinaryReader(fsLookup);
int count = (int)(indexReader.BaseStream.Length / 4);
var count = (int)(indexReader.BaseStream.Length / 4);
TileList[][] lists = new TileList[8][];
var lists = new TileList[8][];
for (int x = 0; x < 8; ++x)
for (var x = 0; x < 8; ++x)
{
lists[x] = new TileList[8];
for (int y = 0; y < 8; ++y)
for (var y = 0; y < 8; ++y)
lists[x][y] = new TileList();
}
for (int i = 0; i < count; ++i)
for (var i = 0; i < count; ++i)
{
int blockID = indexReader.ReadInt32();
int blockX = blockID / matrix.BlockHeight;
int blockY = blockID % matrix.BlockHeight;
var blockID = indexReader.ReadInt32();
var blockX = blockID / matrix.BlockHeight;
var blockY = blockID % matrix.BlockHeight;
int offset = lookupReader.ReadInt32();
int length = lookupReader.ReadInt32();
var offset = lookupReader.ReadInt32();
var length = lookupReader.ReadInt32();
lookupReader.ReadInt32(); // Extra
if (offset < 0 || length <= 0)
@ -144,12 +144,12 @@ namespace Server
fsData.Seek(offset, SeekOrigin.Begin);
int tileCount = length / 7;
var tileCount = length / 7;
if (m_TileBuffer.Length < tileCount)
m_TileBuffer = new StaticTile[tileCount];
StaticTile[] staTiles = m_TileBuffer;
var staTiles = m_TileBuffer;
fixed (StaticTile* pTiles = staTiles)
{
@ -162,13 +162,13 @@ namespace Server
pCur = pCur + 1;
}
StaticTile[][][] tiles = new StaticTile[8][][];
var tiles = new StaticTile[8][][];
for (int x = 0; x < 8; ++x)
for (var x = 0; x < 8; ++x)
{
tiles[x] = new StaticTile[8][];
for (int y = 0; y < 8; ++y)
for (var y = 0; y < 8; ++y)
tiles[x][y] = lists[x][y].ToArray();
}