Snapshot for release 2026.10.11.1 (internal d20160b)
This commit is contained in:
parent
e6fffb0f42
commit
504a6f080a
66 changed files with 7865 additions and 310 deletions
|
|
@ -52,10 +52,16 @@ public static class VTankLootParser
|
|||
idx = 1;
|
||||
}
|
||||
profile.FileVersion = fileVersion;
|
||||
profile.DeclaredRuleCount = ruleCount;
|
||||
|
||||
bool v1Plus = fileVersion >= 1;
|
||||
|
||||
while (idx < lines.Length && profile.Rules.Count < ruleCount)
|
||||
// Past the header's count, keep going while the next lines still look like a
|
||||
// rule: an undercounted header (T10locky.utl declared 134 of its 136 rules)
|
||||
// would otherwise drop the last rules silently. The SalvageCombine block never
|
||||
// matches, its third line having no ';'.
|
||||
while (idx < lines.Length
|
||||
&& (profile.Rules.Count < ruleCount || IsStartOfNextRule(lines, idx, fileVersion)))
|
||||
{
|
||||
var rule = new VTankLootRule
|
||||
{
|
||||
|
|
@ -101,11 +107,16 @@ public static class VTankLootParser
|
|||
var data = new List<string>();
|
||||
if (dataLineCount < 0)
|
||||
{
|
||||
// Unknown type — slurp lines until we look like the start
|
||||
// of the next rule. This mirrors the plugin's previous
|
||||
// heuristic and at least keeps the bytes preserved.
|
||||
while (idx < lines.Length && !IsStartOfNextRule(lines, idx, fileVersion))
|
||||
data.Add(lines[idx++]);
|
||||
// Unknown type. The v1+ length code is the byte length of the data
|
||||
// block (CRLF per line), so it bounds the block exactly; the old
|
||||
// "slurp until something looks like a rule" fallback swallowed the
|
||||
// rest of a multi-condition rule and the rules after it, and a
|
||||
// trailing unknown node ate the SalvageCombine block.
|
||||
if (!TryReadByLengthCode(lines, ref idx, lengthCode, data))
|
||||
{
|
||||
while (idx < lines.Length && !IsStartOfNextRule(lines, idx, fileVersion))
|
||||
data.Add(lines[idx++]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -165,6 +176,39 @@ public static class VTankLootParser
|
|||
return cfg;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads an unknown node's data lines using its length code: each line counts its
|
||||
/// length plus 2 for the CRLF the writer emits. Succeeds only when the lines add up
|
||||
/// to a positive code exactly (as characters for ANSI files, or UTF-8 bytes); otherwise
|
||||
/// <paramref name="idx"/> and <paramref name="data"/> are left untouched so the
|
||||
/// caller can fall back to the boundary heuristic.
|
||||
/// </summary>
|
||||
private static bool TryReadByLengthCode(string[] lines, ref int idx, string lengthCode, List<string> data)
|
||||
{
|
||||
// 0 is what VTankLootWriter emits for a condition built in code, so it says
|
||||
// nothing about the data's size.
|
||||
if (!int.TryParse(lengthCode.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int target)
|
||||
|| target <= 0)
|
||||
return false;
|
||||
|
||||
int charTotal = 0, byteTotal = 0, i = idx;
|
||||
// UTF-8 bytes >= chars, so the char total is the last one to reach the target.
|
||||
while (i < lines.Length && charTotal < target)
|
||||
{
|
||||
charTotal += lines[i].Length + 2;
|
||||
byteTotal += System.Text.Encoding.UTF8.GetByteCount(lines[i]) + 2;
|
||||
i++;
|
||||
if (charTotal == target || byteTotal == target)
|
||||
{
|
||||
for (int j = idx; j < i; j++)
|
||||
data.Add(lines[j]);
|
||||
idx = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Heuristic boundary detection for unknown node types — true if the lines
|
||||
/// starting at `index` could plausibly be a new rule (name + custom-expr +
|
||||
|
|
|
|||
|
|
@ -113,6 +113,13 @@ public sealed class VTankLootProfile
|
|||
|
||||
public List<VTankLootRule> Rules { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The rule count in the file's header, or -1 when not loaded from a file. The parser
|
||||
/// keeps reading rules that follow past this count, so it can be lower than
|
||||
/// <see cref="Rules"/>.Count for a file whose header was written wrong.
|
||||
/// </summary>
|
||||
public int DeclaredRuleCount { get; set; } = -1;
|
||||
|
||||
/// <summary>Optional SalvageCombine block at the end of the file.</summary>
|
||||
public SalvageCombineSettings? SalvageCombine { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue