OpenRA/OpenRA · error · Exception
File name table in .meg file inconsistent
Error message
File name table in .meg file inconsistent
What it means
Thrown by MegFile after reading the filename string table, when the stream position does not equal stringsStart + stringsSize. The header declares the total byte size of the filename table; after reading numStrings entries the parser validates it landed exactly where expected. A mismatch indicates the file is internally inconsistent — either the declared sizes are wrong or string lengths are misaligned.
Source
Thrown at OpenRA.Mods.Cnc/FileSystem/MegFile.cs:84
var headerSize = s.ReadUInt32();
var numStrings = s.ReadUInt32();
var numFiles = s.ReadUInt32();
var stringsSize = s.ReadUInt32();
var stringsStart = s.Position;
var filenames = new List<string>();
// The file names are an indexed array of strings
for (var i = 0; i < numStrings; i++)
{
var length = s.ReadUInt16();
filenames.Add(s.ReadASCII(length));
}
// The header indicates where we should be, so verify it
if (s.Position != stringsSize + stringsStart)
throw new Exception("File name table in .meg file inconsistent");
// Now we load each file entry and associated info
contents = new Dictionary<string, (uint Offset, int Length)>((int)numFiles);
for (var i = 0; i < numFiles; i++)
{
// Ignore flags, crc, index
s.Position += 10;
var size = s.ReadUInt32();
var offset = s.ReadUInt32();
var nameIndex = s.ReadUInt16();
contents[filenames[nameIndex]] = (offset, (int)size);
}
contents.TrimExcess();
if (s.Position != headerSize)
throw new Exception("Expected to be at data start offset");
}View on GitHub (pinned to a520984d91)
Solutions
- Re-pack the .meg archive using a known-compatible tool (e.g. the original game's toolchain or a community MEG editor).
- Compare the file against a known-good .meg from the same game to detect structural differences.
- Inspect the header fields (numStrings, stringsSize) in a hex editor against the actual data layout.
- Replace the archive with an original, unmodified copy.
Defensive patterns
Strategy: validation
Validate before calling
// After reading filename strings, validate position
if (s.Position != stringsSize + stringsStart)
// The MEG filename table is corrupted; reject the archive Try / catch
try { meg = new MegFile(stream, filename); } catch (Exception ex) when (ex.Message.Contains("inconsistent")) { /* handle corrupt MEG */ } Prevention
- Use well-tested MEG packing tools.
- Keep original game archives unmodified.
- Validate file integrity after any repacking operation.
When it happens
Trigger: After the loop reading numStrings entries (each a uint16 length + ASCII string), s.Position != stringsSize + stringsStart. Triggered when mounting a .meg archive whose filename table is malformed.
Common situations: The .meg file was produced by a packing tool that mislabeled string lengths or counts; the file uses a different string encoding (e.g. UTF-16 vs ASCII); the file is truncated within the filename table region; byte-order differences between platforms.
Related errors
- Expected to be at data start offset
- Invalid file signature for meg file
- Unknown sub-chunk {type}
- Invalid vxl header
- Trimmed frame has non-integer offset.
AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13).
Data as JSON: /api/errors/7e030762a785cd82.
Report an issue: GitHub.