mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-13 15:34:36 +01:00
Initial commit
This commit is contained in:
10
DataFixupUtil/DataFixupUtil.csproj
Normal file
10
DataFixupUtil/DataFixupUtil.csproj
Normal file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
57
DataFixupUtil/Program.cs
Normal file
57
DataFixupUtil/Program.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
namespace DataFixupUtil
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
|
||||
foreach(var arg in Directory.GetFiles("C:\\NIKKE\\NIKKE\\Game"))
|
||||
{
|
||||
var fileName = Path.GetFileName(arg);
|
||||
if (fileName.StartsWith("input"))
|
||||
{
|
||||
byte[] FileContents = File.ReadAllBytes(arg);
|
||||
using MemoryStream ms = new MemoryStream(FileContents);
|
||||
File.WriteAllBytes("fullPkt-decr", ms.ToArray());
|
||||
|
||||
var unkVal1 = ms.ReadByte();
|
||||
var pktLen = ms.ReadByte() & 0x1f;
|
||||
|
||||
|
||||
var seqNumB = ms.ReadByte();
|
||||
var seqNum = seqNumB;
|
||||
if (seqNumB >= 24)
|
||||
{
|
||||
var b = ms.ReadByte();
|
||||
|
||||
seqNum = BitConverter.ToUInt16(new byte[] { (byte)b, (byte)seqNumB }, 0);
|
||||
|
||||
// todo support uint32
|
||||
}
|
||||
|
||||
var startPos = (int)ms.Position;
|
||||
|
||||
var contents = FileContents.Skip(startPos).ToArray();
|
||||
if (contents.Length != 0 && contents[0] == 31)
|
||||
{
|
||||
// gzip compression is used
|
||||
using Stream csStream = new GZipStream(new MemoryStream(contents), CompressionMode.Decompress);
|
||||
using MemoryStream decoded = new MemoryStream();
|
||||
csStream.CopyTo(decoded);
|
||||
|
||||
contents = decoded.ToArray();
|
||||
File.WriteAllBytes(arg, contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllBytes(arg, contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user