mirror of
https://github.com/soarqin/DSP_Mods_TO.git
synced 2026-02-04 14:12:18 +08:00
WIP
This commit is contained in:
@@ -179,7 +179,7 @@ public class PatchSave
|
||||
try
|
||||
{
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryWriter), new [] { typeof(FileStream) }))
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryWriter), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryWriter")
|
||||
).MatchForward(false,
|
||||
@@ -191,7 +191,7 @@ public class PatchSave
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite0")
|
||||
).MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), "Write", new [] { typeof(long) }))
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BinaryWriter), "Write", [typeof(long)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "FileLengthWrite1")
|
||||
).MatchForward(false,
|
||||
@@ -299,7 +299,7 @@ public class PatchSave
|
||||
try
|
||||
{
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryReader), new [] { typeof(FileStream) }))
|
||||
new CodeMatch(OpCodes.Newobj, AccessTools.Constructor(typeof(BinaryReader), [typeof(FileStream)]))
|
||||
).Set(
|
||||
OpCodes.Call, AccessTools.Method(typeof(PatchSave), "CreateBinaryReader")
|
||||
).MatchForward(false,
|
||||
|
||||
@@ -67,7 +67,7 @@ static class PatchUISaveGame
|
||||
PatchSave.UseCompressSave = true;
|
||||
}
|
||||
|
||||
private static UIContext _context = new UIContext();
|
||||
private static UIContext _context = new();
|
||||
|
||||
[HarmonyPatch(typeof(UISaveGameWindow), "_OnOpen"), HarmonyPostfix]
|
||||
private static void _OnOpen(UISaveGameWindow __instance)
|
||||
|
||||
@@ -84,7 +84,7 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(byte value)
|
||||
{
|
||||
CheckCapacityAndSwap(1);
|
||||
*(_curPos++) = value;
|
||||
*_curPos++ = value;
|
||||
}
|
||||
|
||||
public override void Write(bool value) => Write((byte)(value ? 1 : 0));
|
||||
@@ -168,15 +168,15 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(double value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
ulong num = (ulong)(*(long*)(&value));
|
||||
*(_curPos++) = (byte)num;
|
||||
*(_curPos++) = (byte)(num >> 8);
|
||||
*(_curPos++) = (byte)(num >> 16);
|
||||
*(_curPos++) = (byte)(num >> 24);
|
||||
*(_curPos++) = (byte)(num >> 32);
|
||||
*(_curPos++) = (byte)(num >> 40);
|
||||
*(_curPos++) = (byte)(num >> 48);
|
||||
*(_curPos++) = (byte)(num >> 56);
|
||||
ulong num = (ulong)*(long*)&value;
|
||||
*_curPos++ = (byte)num;
|
||||
*_curPos++ = (byte)(num >> 8);
|
||||
*_curPos++ = (byte)(num >> 16);
|
||||
*_curPos++ = (byte)(num >> 24);
|
||||
*_curPos++ = (byte)(num >> 32);
|
||||
*_curPos++ = (byte)(num >> 40);
|
||||
*_curPos++ = (byte)(num >> 48);
|
||||
*_curPos++ = (byte)(num >> 56);
|
||||
}
|
||||
|
||||
//slow
|
||||
@@ -195,15 +195,15 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
public override void Write(short value)
|
||||
{
|
||||
CheckCapacityAndSwap(2);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
}
|
||||
|
||||
public override void Write(ushort value)
|
||||
{
|
||||
CheckCapacityAndSwap(2);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,56 +213,56 @@ public unsafe class BufferWriter : BinaryWriter
|
||||
{
|
||||
SwapBuffer();
|
||||
}
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
}
|
||||
|
||||
public override void Write(uint value)
|
||||
{
|
||||
CheckCapacityAndSwap(4);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
}
|
||||
|
||||
|
||||
public override void Write(long value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*(_curPos++) = (byte)(value >> 32);
|
||||
*(_curPos++) = (byte)(value >> 40);
|
||||
*(_curPos++) = (byte)(value >> 48);
|
||||
*(_curPos++) = (byte)(value >> 56);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)(value >> 32);
|
||||
*_curPos++ = (byte)(value >> 40);
|
||||
*_curPos++ = (byte)(value >> 48);
|
||||
*_curPos++ = (byte)(value >> 56);
|
||||
}
|
||||
|
||||
public override void Write(ulong value)
|
||||
{
|
||||
CheckCapacityAndSwap(8);
|
||||
*(_curPos++) = (byte)value;
|
||||
*(_curPos++) = (byte)(value >> 8);
|
||||
*(_curPos++) = (byte)(value >> 16);
|
||||
*(_curPos++) = (byte)(value >> 24);
|
||||
*(_curPos++) = (byte)(value >> 32);
|
||||
*(_curPos++) = (byte)(value >> 40);
|
||||
*(_curPos++) = (byte)(value >> 48);
|
||||
*(_curPos++) = (byte)(value >> 56);
|
||||
*_curPos++ = (byte)value;
|
||||
*_curPos++ = (byte)(value >> 8);
|
||||
*_curPos++ = (byte)(value >> 16);
|
||||
*_curPos++ = (byte)(value >> 24);
|
||||
*_curPos++ = (byte)(value >> 32);
|
||||
*_curPos++ = (byte)(value >> 40);
|
||||
*_curPos++ = (byte)(value >> 48);
|
||||
*_curPos++ = (byte)(value >> 56);
|
||||
}
|
||||
|
||||
public override void Write(float value)
|
||||
{
|
||||
CheckCapacityAndSwap(4);
|
||||
uint num = *(uint*)(&value);
|
||||
*(_curPos++) = (byte)num;
|
||||
*(_curPos++) = (byte)(num >> 8);
|
||||
*(_curPos++) = (byte)(num >> 16);
|
||||
*(_curPos++) = (byte)(num >> 24);
|
||||
uint num = *(uint*)&value;
|
||||
*_curPos++ = (byte)num;
|
||||
*_curPos++ = (byte)(num >> 8);
|
||||
*_curPos++ = (byte)(num >> 16);
|
||||
*_curPos++ = (byte)(num >> 24);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ public class DoubleBuffer(byte[] readingBuffer, byte[] writingBuffer, Action onR
|
||||
private ByteSpan _readBuffer;
|
||||
private ByteSpan _midBuffer = new(readingBuffer);
|
||||
|
||||
private readonly Semaphore _readEnd = new Semaphore(1, 1);
|
||||
private readonly Semaphore _writeEnd = new Semaphore(0, 1);
|
||||
private readonly Semaphore _readEnd = new(1, 1);
|
||||
private readonly Semaphore _writeEnd = new(0, 1);
|
||||
|
||||
public ByteSpan ReadBegin()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user