mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Skip to payload end instead of reading remaining bytes
This commit is contained in:
parent
327ebf3bb3
commit
93a44842ed
1 changed files with 3 additions and 7 deletions
|
|
@ -2,11 +2,8 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using Dalamud.Data;
|
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using Dalamud.Plugin.Services;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
// TODOs:
|
// TODOs:
|
||||||
|
|
@ -117,7 +114,7 @@ public abstract partial class Payload
|
||||||
var chunkType = (SeStringChunkType)reader.ReadByte();
|
var chunkType = (SeStringChunkType)reader.ReadByte();
|
||||||
var chunkLen = GetInteger(reader);
|
var chunkLen = GetInteger(reader);
|
||||||
|
|
||||||
var packetStart = reader.BaseStream.Position;
|
var expressionsStart = reader.BaseStream.Position;
|
||||||
|
|
||||||
// any unhandled payload types will be turned into a RawPayload with the exact same binary data
|
// any unhandled payload types will be turned into a RawPayload with the exact same binary data
|
||||||
switch (chunkType)
|
switch (chunkType)
|
||||||
|
|
@ -210,9 +207,8 @@ public abstract partial class Payload
|
||||||
payload ??= new RawPayload((byte)chunkType);
|
payload ??= new RawPayload((byte)chunkType);
|
||||||
payload.DecodeImpl(reader, reader.BaseStream.Position + chunkLen);
|
payload.DecodeImpl(reader, reader.BaseStream.Position + chunkLen);
|
||||||
|
|
||||||
// read through the rest of the packet
|
// skip to the end of the payload, in case the specific payload handler didn't read everything
|
||||||
var readBytes = (uint)(reader.BaseStream.Position - packetStart);
|
reader.BaseStream.Seek(expressionsStart + chunkLen + 1, SeekOrigin.Begin); // +1 for the END_BYTE marker
|
||||||
reader.ReadBytes((int)(chunkLen - readBytes + 1)); // +1 for the END_BYTE marker
|
|
||||||
|
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue