Source code cleanup.
parent
24e7674f57
commit
567f8b7e4a
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<solution>
|
<solution>
|
||||||
<add key="disableSourceControlIntegration" value="true" />
|
<add key="disableSourceControlIntegration" value="true" />
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String></wpf:ResourceDictionary>
|
|
@ -67,10 +67,6 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> RequiredContent { get; private set; }
|
public List<string> RequiredContent { get; private set; }
|
||||||
|
|
||||||
public static void CreateFromFolder()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Imports a gmod addon into this instance.
|
/// Imports a gmod addon into this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -5,10 +5,10 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
{
|
{
|
||||||
public class SegmentedAddonFileInfo : AddonFileInfo
|
public class SegmentedAddonFileInfo : AddonFileInfo
|
||||||
{
|
{
|
||||||
|
private readonly int _hash;
|
||||||
private readonly long _len;
|
private readonly long _len;
|
||||||
private readonly long _pos;
|
private readonly long _pos;
|
||||||
private readonly Stream _stream;
|
private readonly Stream _stream;
|
||||||
private int _hash;
|
|
||||||
|
|
||||||
public SegmentedAddonFileInfo(Stream stream, long pos, long len, int fileHash)
|
public SegmentedAddonFileInfo(Stream stream, long pos, long len, int fileHash)
|
||||||
{
|
{
|
||||||
|
@ -20,10 +20,7 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
|
|
||||||
public override long Size
|
public override long Size
|
||||||
{
|
{
|
||||||
get
|
get { return _len; }
|
||||||
{
|
|
||||||
return _len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Crc32Hash
|
public override int Crc32Hash
|
||||||
|
|
|
@ -47,11 +47,6 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Addon\AddonFile.cs" />
|
<Compile Include="Addon\AddonFile.cs" />
|
||||||
|
|
|
@ -19,14 +19,14 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
uint i;
|
uint i;
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
uint r = i;
|
var r = i;
|
||||||
for (int j = 0; j < 8; j++)
|
for (var j = 0; j < 8; j++)
|
||||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||||
Table[i] = r;
|
Table[i] = r;
|
||||||
}
|
}
|
||||||
for (; i < 256*CRC_NUM_TABLES; i++)
|
for (; i < 256*CRC_NUM_TABLES; i++)
|
||||||
{
|
{
|
||||||
uint r = Table[i - 256];
|
var r = Table[i - 256];
|
||||||
Table[i] = Table[r & 0xFF] ^ (r >> 8);
|
Table[i] = Table[r & 0xFF] ^ (r >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
|
|
||||||
var table = Table; // important for performance!
|
var table = Table; // important for performance!
|
||||||
|
|
||||||
uint crc = value;
|
var crc = value;
|
||||||
|
|
||||||
for (; (offset & 7) != 0 && count != 0; count--)
|
for (; (offset & 7) != 0 && count != 0; count--)
|
||||||
crc = (crc >> 8) ^ table[(byte) crc ^ data[offset++]];
|
crc = (crc >> 8) ^ table[(byte) crc ^ data[offset++]];
|
||||||
|
@ -73,7 +73,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
* Idea from 7-zip project sources (http://7-zip.org/sdk.html)
|
* Idea from 7-zip project sources (http://7-zip.org/sdk.html)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int to = (count - 8) & ~7;
|
var to = (count - 8) & ~7;
|
||||||
count -= to;
|
count -= to;
|
||||||
to += offset;
|
to += offset;
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
var r = (uint) i;
|
var r = (uint) i;
|
||||||
for (int j = 0; j < 8; j++)
|
for (var j = 0; j < 8; j++)
|
||||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||||
Table[i] = r;
|
Table[i] = r;
|
||||||
}
|
}
|
||||||
for (; i < 256*CRC_NUM_TABLES; i++)
|
for (; i < 256*CRC_NUM_TABLES; i++)
|
||||||
{
|
{
|
||||||
uint r = Table[i - 256];
|
var r = Table[i - 256];
|
||||||
Table[i] = Table[r & 0xFF] ^ (r >> 8);
|
Table[i] = Table[r & 0xFF] ^ (r >> 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
|
|
||||||
// choose optimal number of threads to use
|
// choose optimal number of threads to use
|
||||||
|
|
||||||
int threadCount = ThreadCount;
|
var threadCount = ThreadCount;
|
||||||
L0:
|
L0:
|
||||||
int bytesPerThread = (count + threadCount - 1)/threadCount;
|
var bytesPerThread = (count + threadCount - 1)/threadCount;
|
||||||
if (bytesPerThread < ThreadCost >> 1)
|
if (bytesPerThread < ThreadCost >> 1)
|
||||||
{
|
{
|
||||||
threadCount--;
|
threadCount--;
|
||||||
|
@ -115,7 +115,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
|
|
||||||
if (count >= 8)
|
if (count >= 8)
|
||||||
{
|
{
|
||||||
int to = (count - 8) & ~7;
|
var to = (count - 8) & ~7;
|
||||||
count -= to;
|
count -= to;
|
||||||
to += offset;
|
to += offset;
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
Prepare_even_odd_Cache();
|
Prepare_even_odd_Cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint[] even = CopyArray(even_cache);
|
var even = CopyArray(even_cache);
|
||||||
uint[] odd = CopyArray(odd_cache);
|
var odd = CopyArray(odd_cache);
|
||||||
|
|
||||||
crc1 = ~crc1;
|
crc1 = ~crc1;
|
||||||
crc2 = ~crc2;
|
crc2 = ~crc2;
|
||||||
|
@ -225,7 +225,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
|
|
||||||
// put operator for one zero bit in odd
|
// put operator for one zero bit in odd
|
||||||
odd[0] = kCrcPoly; // the CRC-32 polynomial
|
odd[0] = kCrcPoly; // the CRC-32 polynomial
|
||||||
for (int i = 1; i < 32; i++) odd[i] = 1U << (i - 1);
|
for (var i = 1; i < 32; i++) odd[i] = 1U << (i - 1);
|
||||||
|
|
||||||
// put operator for two zero bits in even
|
// put operator for two zero bits in even
|
||||||
gf2_matrix_square(even, odd);
|
gf2_matrix_square(even, odd);
|
||||||
|
@ -241,7 +241,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
private static uint gf2_matrix_times(uint[] matrix, uint vec)
|
private static uint gf2_matrix_times(uint[] matrix, uint vec)
|
||||||
{
|
{
|
||||||
uint sum = 0;
|
uint sum = 0;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
while (vec != 0)
|
while (vec != 0)
|
||||||
{
|
{
|
||||||
if ((vec & 1) != 0) sum ^= matrix[i];
|
if ((vec & 1) != 0) sum ^= matrix[i];
|
||||||
|
@ -255,7 +255,7 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
/// <param name="mat">will not be modified</param>
|
/// <param name="mat">will not be modified</param>
|
||||||
private static void gf2_matrix_square(uint[] square, uint[] mat)
|
private static void gf2_matrix_square(uint[] square, uint[] mat)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 32; i++)
|
for (var i = 0; i < 32; i++)
|
||||||
square[i] = gf2_matrix_times(mat, mat[i]);
|
square[i] = gf2_matrix_times(mat, mat[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ namespace GarrysMod.AddonCreator.Hashing
|
||||||
Table = new uint[256];
|
Table = new uint[256];
|
||||||
for (uint i = 0; i < 256; i++)
|
for (uint i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
uint r = i;
|
var r = i;
|
||||||
for (int j = 0; j < 8; j++)
|
for (var j = 0; j < 8; j++)
|
||||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||||
Table[i] = r;
|
Table[i] = r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ namespace GarrysMod.AddonCreator
|
||||||
|
|
||||||
if (!folder.Exists)
|
if (!folder.Exists)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("ERROR: Input folder needs to exist and needs to contain appropriate data.");
|
Console.Error.WriteLine(
|
||||||
|
"ERROR: Input folder needs to exist and needs to contain appropriate data.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ namespace GarrysMod.AddonCreator
|
||||||
{
|
{
|
||||||
addon.Import(gma);
|
addon.Import(gma);
|
||||||
}
|
}
|
||||||
catch(Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("ERROR: Input GMA file could not be read - {0}", err.Message);
|
Console.Error.WriteLine("ERROR: Input GMA file could not be read - {0}", err.Message);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
Loading…
Reference in New Issue