egametang/ET · error · Exception
{e.Message}
Error message
{e.Message} What it means
CompressTileCacheLayer wraps the underlying byte compression in a try/catch and rethrows any IOException as a generic Exception whose message is the original IOException's message (and chains it as inner). The thrown text is therefore the compressor/IO error verbatim, e.g. a buffer or stream failure from IRcCompressor.Compress. The real cause is an IO/compression failure during layer serialization.
Source
Thrown at Packages/cn.etetet.recast/Scripts/Core/Share/Detour.TileCache/DtTileCacheBuilder.cs:1931
try
{
hw.Write(bw, layer.header, order, cCompatibility);
int gridSize = layer.header.width * layer.header.height;
byte[] buffer = new byte[gridSize * 3];
for (int i = 0; i < gridSize; i++)
{
buffer[i] = (byte)layer.heights[i];
buffer[gridSize + i] = (byte)layer.areas[i];
buffer[gridSize * 2 + i] = (byte)layer.cons[i];
}
var compressed = comp.Compress(buffer);
bw.Write(compressed);
return ms.ToArray();
}
catch (IOException e)
{
throw new Exception(e.Message, e);
}
}
public byte[] CompressTileCacheLayer(DtTileCacheLayerHeader header, int[] heights, int[] areas, int[] cons, RcByteOrder order, bool cCompatibility, IRcCompressor comp)
{
using var ms = new MemoryStream();
using var bw = new BinaryWriter(ms);
DtTileCacheLayerHeaderWriter hw = new DtTileCacheLayerHeaderWriter();
try
{
hw.Write(bw, header, order, cCompatibility);
int gridSize = header.width * header.height;
byte[] buffer = new byte[gridSize * 3];
for (int i = 0; i < gridSize; i++)
{
buffer[i] = (byte)heights[i];
buffer[gridSize + i] = (byte)areas[i];
buffer[gridSize * 2 + i] = (byte)cons[i];View on GitHub (pinned to 5cab01f7a8)
Solutions
- Inspect the chained InnerException (the original IOException) for the true cause.
- Validate header.width*height and the heights/areas/cons array lengths equal gridSize before calling.
- If using a custom IRcCompressor, ensure Compress never throws IOException on valid input.
Example fix
// before
byte[] bytes = builder.CompressTileCacheLayer(header, heights, areas, cons, order, cCompat, comp);
// after: validate inputs and surface the real cause
int gridSize = header.width * header.height;
if (heights.Length < gridSize || areas.Length < gridSize || cons.Length < gridSize)
throw new InvalidOperationException("layer arrays smaller than width*height");
try { byte[] bytes = builder.CompressTileCacheLayer(header, heights, areas, cons, order, cCompat, comp); }
catch (Exception ex) { throw new InvalidOperationException("layer compress failed", ex.InnerException ?? ex); } Defensive patterns
Strategy: try-catch
Validate before calling
int gridSize = header.width * header.height;
if (heights.Length < gridSize || areas.Length < gridSize || cons.Length < gridSize)
throw new InvalidOperationException("layer arrays smaller than width*height");
byte[] bytes = builder.CompressTileCacheLayer(header, heights, areas, cons, order, cCompat, comp); Try / catch
try { return builder.CompressTileCacheLayer(header, heights, areas, cons, order, cCompat, comp); }
catch (Exception e) { throw new InvalidDataException("layer compress failed", e.InnerException ?? e); } Prevention
- Always inspect ex.InnerException for the real IOException.
- Validate header.width*height against array lengths first.
- Confirm IRcCompressor.Compress is robust on valid input.
When it happens
Trigger: Calling CompressTileCacheLayer when IRcCompressor.Compress throws (bad buffer, unsupported format, or a custom compressor fault); writing to a MemoryStream that is closed/disposed.
Common situations: A custom IRcCompressor implementation raising IOException; malformed header (width*height producing wrong gridSize) feeding a too-small buffer; endianness/C-compat flag mismatch corrupting the stream mid-write.
Related errors
- Invalid magic
- Invalid version
- Invalid magic
- Invalid version
- location add failed key: {key} actorId: {actorId} error: {re
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/01847ace1f1f34c4.
Report an issue: GitHub.